Reply to Re: PHP 5 limits "readfile" to 1.9 MB?

Your name:

Reply:


Posted by Catalin Trifu on 08/17/05 11:36

Hi,

I've had a similar problem. The download always stopped at exactly 2.000.000 bytes.
You have to work around that with:
$fp = fopen($file, 'r');
if($fp) {
while(!feof($fp)) {
echo fread($fp, 1024768);//see the huge buffer to read into
}
} else {
//whatever error handler
}

Catalin


Jordan Miller wrote:
> Hello all,
>
> I am new to this list and I have searched the archives to no avail. I
> am having a peculiar problem when upgrading to PHP 5: My downloads are
> now limited to the first 1.9 MB of the file in question, with the
> download either terminating at 1.9 MB or seemingly continuously stuck
> in a downloading process at 1.9 MB. The code in the PHP script has not
> changed and all parameters that I could find that are relevant to this
> problem are given below:
>
> the minimal code needed for download:
> // $file_to_read is the complete path of the file to download
> header("Content-Type: application/pdf");
> header( "Content-Disposition: inline; filename=\"$filename\"");
> $len = filesize($file_to_read);
> header("Content-Length: $len");
> @readfile($file_to_read);
>
> php.ini file for both php version 4 and 5 contain the following
> settings that may be relevant:
>
> allow_url_fopen = On
> max_execution_time = 300 ; Maximum execution time of each script,
> in seconds
> max_input_time = 300 ; Maximum amount of time each script may spend
> parsing request data
> memory_limit = 8M ; Maximum amount of memory a script may consume
> (8MB)
> post_max_size = 200M
> upload_max_filesize = 200M
>
>
> Some additional details:
> All files less than 1.9 MB download fine
> It is not a corrupted file, because all files larger than 1.9 MB fail
> after 1.9 MB
> The connection is not timing out (download of 1.9 MB takes only ~15 sec)
> Mac OS X 10.3.9 with Marc Liyanage's PHP 5.0.4
> Fails for both Safari and Firefox
> Fails regardless of "inline" or "attachment"
> Fails regardless of "pdf" or "ppt" content-type
> This PHP code ALWAYS works for Marc Liyanage's PHP 4.3.4 with the same
> settings, above
>
>
> What am I doing wrong??? Any other parameter in php.ini I should have
> set? Any suggestions are much appreciated.
>
> thanks,
> Jordan

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация