note 107872 modified in function.copy by drak

From: Date: Mon, 12 Mar 2012 13:44:17 +0000
Subject: note 107872 modified in function.copy by drak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-186610@lists.php.net to get a copy of this message
&lt;?php $from =\\&#039;http://example.com/somefile.zip\\&#039;; $to=\\&#039;./somefile.zip\\&#039;; if (!@copy($from,$to)) { $errors= error_get_last(); echo \\&quot;COPY ERROR: \\&quot;.$errors[\\&#039;type\\&#039;]; echo \\&quot;&lt;br /&gt;\\\\n\\&quot;.$errors[\\&#039;message\\&#039;]; } else { echo \\&quot;File copied from remote!\\&quot;; } what if we don\\&#039;t know the file name and extension? eg $from =\\&#039;http://example.com/download.php?id=123\\&#039;; $to= ??? --was-- <?php $from ='http://someserver.com/somefile.zip'; $to='./somefile.zip'; i f(!@copy($from,$to)) { $errors= error_get_last(); echo "COPY ERROR: ".$errors['type']; echo "<br />\n".$errors['message']; } else { echo "File copied from remote!"; } what if we don't know the file name and extension? eg $from ='http://someserver.com/download.php?id=123'; $to= ??? ?> http://php.net/manual/en/function.copy.php

« previous php.notes (#186610) next »