note 107872 modified in function.copy by drak
| From: | drak@php.net | 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 | ||
<?php
$from =\\'http://example.com/somefile.zip\\';
$to=\\'./somefile.zip\\';
if (!@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://example.com/download.php?id=123\\';
$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