note 37362 deleted from function.readfile by pollita
| From: | pollita@php.net | Date: | Wed, 12 Nov 2003 05:57:00 +0000 |
| Subject: | note 37362 deleted from function.readfile by pollita | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-60278@lists.php.net to get a copy of this message | ||
Note Submitter: synace@nospam.synace.com
----
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.