Re: [PHP] Input variable from form help request
On 29 September 2011 23:28, PHProg php...@speedemessenger.com wrote: Hello Richard, Your suggestion worked perfectly. ... it works beautifully. Now that's what I like to hear! Glad to be of help. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Input variable from form help request
On 29 September 2011 13:30, PHProg php...@speedemessenger.com wrote: ?php if(!@copy('http://mydomain.com/files/ .$_POST['trakname'].','/.$_POST['dirname']./.$_POST['trakname'].')) { $errors= error_get_last(); echo COPY ERROR: .$errors['type']; echo br /\n.$errors['message']; } else { echo File copied from remote!; } ? Try ... ?php if(!@copy(http://mydomain.com/files/{$_POST['trakname']}, /{$_POST['dirname']}/{$_POST['trakname']})) { $errors= error_get_last(); echo 'COPY ERROR: ', $errors['type'], 'br /', PHP_EOL, $errors['message']; } else { echo 'File copied from remote!'; } ? You need to keep track of the opening and closing quotes (single and double). In the copy() function, I'm using the embedded variable method (a string using double quotes will evaluate the variables at run time). In the echo statements, I'm not using concatenation as, theoretically, it should be faster as the echo statement will not need to first build the concatenated string before echoing it. It will just push the values out the to the web server. I think. I've not done any metric testing on that. As for copying a file TO a http URL, you need to obey the rules of http. CURL or FTP will be the protocols of choice here, though you do have the option of using a stream context to wrap the file_put_contents() into a POST form to the site (similar to CURL in some ways). -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Input variable from form help request
On 29 Sep 2011 at 13:30, PHProg php...@speedemessenger.com wrote: I'm trying to create a standard web form that will use a PHP script to copy a file from one server to another. [snip] ?php if(!@copy('http://mydomain.com/files/.$_POST['trakname'].','/.$_POST['dirna me']./.$_POST['trakname'].')) This line: if(!@copy('http://mydomain.com/files/.$_POST['trakname'].','/.$_POST['dirname']./.$_POST['trakname'].')) looks like a big mess of single and double quotes to me. Why don't you go through it very carefully? I'd be inclined to make a small test program separate from the web page stuff and do things like: ?php $_POST['trakname'] = abc; // similar for the other two $myvar = 'http://mydomain.com/files/.$_POST['trakname'].','/.$_POST['dirname']./.$_POST['trakname'].'; echo $myvar; ? and fiddle until that works. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Input variable from form help request
Hello Richard, Your suggestion worked perfectly. Basically, I just copied and pasted your example and with a few, very minor adjustments, it works beautifully. Many thanks for your help. All the best. At 08:43 AM Thursday 9/29/2011, Richard Quadling wrote: On 29 September 2011 13:30, PHProg php...@speedemessenger.com wrote: ?php if(!@copy('http://mydomain.com/files/ .$_POST['trakname'].','/.$_POST['dirname']./.$_POST['trakname'].')) { Â Â $errors= error_get_last(); Â Â echo COPY ERROR: .$errors['type']; Â Â echo br /\n.$errors['message']; } else { Â Â echo File copied from remote!; } ? Try ... ?php if(!@copy(http://mydomain.com/files/{$_POST['trakname']}, /{$_POST['dirname']}/{$_POST['trakname']})) { $errors= error_get_last(); echo 'COPY ERROR: ', $errors['type'], 'br /', PHP_EOL, $errors['message']; } else { echo 'File copied from remote!'; } ? You need to keep track of the opening and closing quotes (single and double). In the copy() function, I'm using the embedded variable method (a string using double quotes will evaluate the variables at run time). In the echo statements, I'm not using concatenation as, theoretically, it should be faster as the echo statement will not need to first build the concatenated string before echoing it. It will just push the values out the to the web server. I think. I've not done any metric testing on that. As for copying a file TO a http URL, you need to obey the rules of http. CURL or FTP will be the protocols of choice here, though you do have the option of using a stream context to wrap the file_put_contents() into a POST form to the site (similar to CURL in some ways). -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php