Buffer output limit??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dle46163
Forum Newbie
Posts: 2
Joined: Wed Feb 17, 2010 10:23 pm

Buffer output limit??

Post 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;
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Buffer output limit??

Post by requinix »

Code: Select all

$fp = fopen($url, 'rb');
$buffer = fread($fp, filesize($url));
fclose ($fp);
 
print $buffer;
Just use readfile instead.
dle46163
Forum Newbie
Posts: 2
Joined: Wed Feb 17, 2010 10:23 pm

Re: Buffer output limit??

Post by dle46163 »

Perfect, readfile did the trick! Thank you!
Post Reply