Page 1 of 1

Buffer output limit??

Posted: Wed Feb 17, 2010 10:32 pm
by dle46163
Hi,

I have a web app that uses the same script in multiple places - the script causes the web browser to prompt a user to open or save a file that is located in an area only accessible by the web server. It's been working fine for a looong time but today I noticed that the script no longer allows me to download files larger than 20mb. The only thing * I know * has changed is an upgrade from PHP 5.0.4 to 5.2.11, roughly two months ago. Beyond that, I have no clue what is going on. Below is the code that was working and now is not (for larger files...small files work fine). Can anyone offer some insight? Thanks soooo much! -chris

$mm_type="application/octet-stream";
header("Cache-Control: public, must-revalidate");
header("Pragma: hack");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($url)) );
header('Content-Disposition: attachment; filename="'.basename($url).'"');
header("Content-Transfer-Encoding: binary\n");


$fp = fopen($url, 'rb');
$buffer = fread($fp, filesize($url));
fclose ($fp);

print $buffer;

Re: Buffer output limit??

Posted: Thu Feb 18, 2010 1:10 am
by requinix

Code: Select all

$fp = fopen($url, 'rb');
$buffer = fread($fp, filesize($url));
fclose ($fp);
 
print $buffer;
Just use readfile instead.

Re: Buffer output limit??

Posted: Thu Feb 18, 2010 7:26 am
by dle46163
Perfect, readfile did the trick! Thank you!