RE: [PHP] Getting a binary file from URL

From: Date: Sun, 22 Apr 2001 17:34:48 +0000
Subject: RE: [PHP] Getting a binary file from URL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-49752@lists.php.net to get a copy of this message
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:jtorres@elsitio.com.co] Enviado el: domingo 22 de abril de 2001 12:07 Para: php-general@lists.php.net 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: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#49752) next »