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 ...

"/{$_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

Reply via email to