Well, it use to happen...
[from function.filesize.html]
int filesize (string filename)
This function will not work on remote files; the file to be examined must be
accessible via the server's filesystem.
Ok, I screwed up. But now that I know what went wrong, how can I override
this? The docs said: "Fread() reads up to length bytes from the file pointer
referenced by fp. Reading stops when length bytes have been read or EOF is
reached, whichever comes first."
How do I use fread to read until EOF? Note: I don't know the file size, it
could be from 1 byte to xxx Mb.
Thanks,
Jaime
-----Mensaje original-----
De: Jaime Torres [mailto:[EMAIL PROTECTED]]
Enviado el: domingo 22 de abril de 2001 12:07
Para: [EMAIL PROTECTED]
Asunto: [PHP] Getting a binary file from URL
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]