#19886 [Com]: readfile, fread, fpassthru won't work with large files!!!
| From: | harbater at teamgenesis dot com | Date: | Thu, 31 Oct 2002 11:17:56 +0000 |
| Subject: | #19886 [Com]: readfile, fread, fpassthru won't work with large files!!! | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-23780@lists.php.net to get a copy of this message | ||
ID: 19886
Comment by: harbater@teamgenesis.com
Reported By: spic@php.net
Status: Feedback
Bug Type: Filesystem function related
Operating System: Windows, any Version
PHP Version: 4CVS-2002-10-13
New Comment:
I'm experiencing something similar on Linux Apache using Version 4.1.2.
As far as I know it worked before I upgraded from an earlier version.
My code looks like this:
$file="/path/to/file";
$fp = fopen($file, "r");
$size=filesize($file);
$contents = fread($fp, $size);
fclose($fp);
Header("Content-Type: $type");
Header("Content-Disposition: attachment; filename=$downloadname");
header("Content-Length: $size");
header("Content-Transfer-Encoding: binary");
echo $contents;
filesize() is reporting the size properly. The code works perfectly
for smaller files, but the fread() fails for files larger than 19 MB or
so and I got a page cannot be displayed error. All the files being
downloaded are PDF files.
Previous Comments:
------------------------------------------------------------------------
[2002-10-31 04:34:57] selfman@lasercat.de
None of them has been used (output buffering or ob_gzhandler, or
zlib.output_compression or transparent SID/session rewriting). The
fopen() -> $val = fread()-> echo $val worked fine. The response was
much quicker.
Never minad... I have solved the problem otherwise. And the data have
moved to a differen server with higher capacity.
Regards SelfMan
------------------------------------------------------------------------
[2002-10-29 19:13:28] wez@php.net
and did you try the most recent snapshot as I suggested
on the 13 Oct?
And could you reproduce the issue using a different web server?
------------------------------------------------------------------------
[2002-10-29 16:14:28] spic@php.net
For me, I dont have output buffering or ob_gzhandler,
or zlib.output_compression or transparent SID/session rewriting
enabled. I tested even a max execution time of a day.
------------------------------------------------------------------------
[2002-10-29 09:10:49] wez@php.net
As a sanity check, you're not using output buffering or ob_gzhandler,
or zlib.output_compression or transparent
SID/session rewriting, are you?
------------------------------------------------------------------------
[2002-10-29 06:55:29] selfman@lasercat.de
I have a simmilar problem on windows 2000 Server with IIS4.
I use this script (just a part):
header("Content-type: Download");
header("Content-Disposition: attachment;
filename=".$Data->SWFileName);
$fp = fopen ($GLOBALS['FileLocation'].$Data->SWFileName, "rb");
fpassthru($fp);
The problem is that on our development machine (Linux) everything works
like a charm, but on our "Production" server with Win2k Server & IIS
not.
There is a small JavaScript which calls the file sending script usimg
window.location='getfile.php?fileid=56'
The problem place is that the time between request and displaying the
"save" dialog is very large. (1-2 minutes or so) I can't get it to
execute faster.
I will try to use the fread().
Later
SelfMan
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/19886
--
Edit this bug report at http://bugs.php.net/?id=19886&edit=1