note 30492 added to ref.filesystem
| From: | timrosseel at hotmail dot com | Date: | Thu, 20 Mar 2003 00:12:23 +0000 |
| Subject: | note 30492 added to ref.filesystem | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45532@lists.php.net to get a copy of this message | ||
This should copy a file from a URL to the server. It doesn't work. Who knows what's
wrong?
function CopyFileFromURL($URL){
$fp = fopen($URL, "rb");
$filecont = fread ($fp, filesize($URL));
fclose($fp);
$tmpfname = tempnam("/tmp", "tmp");
$temp = fopen($tmpfname, "wb");
fwrite($temp, $filecont);
fclose($temp);
$URL = "files/".substr(strrchr($URL,"/"),1);
if(!copy(realpath(dirname($tmpfname)."/".basename($tmpfname)), realpath($URL))) echo
"Error";
unlink($tmpfname);
}
CopyFileFromURL("http://www.site.com/file.ext";);
--
http://www.php.net/manual/en/ref.filesystem.php
http://master.php.net/manage/user-notes.php?action=edit+30492
http://master.php.net/manage/user-notes.php?action=delete+30492
http://master.php.net/manage/user-notes.php?action=reject+30492