note 26824 added to function.fread

From: Date: Thu, 14 Nov 2002 07:28:52 +0000
Subject: note 26824 added to function.fread
Groups: php.notes 
Request: Send a blank email to php-notes+get-39471@lists.php.net to get a copy of this message
I spent a while trying to get this to work so I thought I'd share. Here's how to read a remote binary file using fread. $fp = fopen("http://www.site.com/img.jpg", "rb"); while(!feof($fp)) { $img = $img . fread($fp, 1024); } This will read the contents of the file into the var $img 1024 bytes at a time. I used that number because it seemed safe, but you can increment it all you want I guess. I don't know if everyone but me gets this, but I thought I'd share since I didn't see anything like it out there. -- http://www.php.net/manual/en/function.fread.php http://master.php.net/manage/user-notes.php?action=edit+26824 http://master.php.net/manage/user-notes.php?action=delete+26824 http://master.php.net/manage/user-notes.php?action=reject+26824

« previous php.notes (#39471) next »