note 37362 added to function.readfile

From: Date: Wed, 12 Nov 2003 04:25:14 +0000
Subject: note 37362 added to function.readfile
Groups: php.notes 
Request: Send a blank email to php-notes+get-60277@lists.php.net to get a copy of this message
instead using readfile for large files (which will take up your php ram allocation) you can use the following: function my_readfile($file) { if ( !$fp = @fopen($file,"r") ) { return false; } while( !@feof($fp) ) { print( @fread($fp, 4096) ); } @fclose($fp); return true; } $result = my_readfile( $file ); before: $result = readfile('path/to/my_large_archive.zip'); after $result = my_readfile('path/to/my_large_archive.zip'); this is very helpful when forcing a browser to download a file using php. ---- Manual Page -- http://www.php.net/manual/en/function.readfile.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37362 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37362&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37362&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60277) next »