Getting a binary file from URL
| From: | Jaime Torres | Date: | Sun, 22 Apr 2001 17:06:51 +0000 |
| Subject: | Getting a binary file from URL | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-49751@lists.php.net to get a copy of this message | ||
Hi, I'm trying to get a binary file from an URL and then save it to a local
disk.
I'm trying this:
$fd = fopen ($filename, "rb");
$contents = fread ($fd, filesize ($filename));
fclose ($fd);
$fp = fopen ($tempfile, "wb");
fwrite ($fp,$contents);
fclose ($fp);
If I use $filename="local_file" the script works great, but if I use
$filename="http://myserver.com/remote_file" the resultant
local file is
empty.
How can I do this?
Thanks in advance,
Jaime