|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29801 Using readfile() to send large files causes PHP to hang
Submitted: 2004-08-23 19:47 UTC Modified: 2004-11-16 00:55 UTC
Avg. Score:4.8 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:0 (0.0%)
From: WPinegar at healthtech dot net Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 5.0.1 OS: Windows Server 2003
Private report: No CVE-ID:
 [2004-08-23 19:47 UTC] WPinegar at healthtech dot net
Attempting to use readfile() to send large (over 250MB) binary objects causes PHP 5.0.1 to hang or the web server to send a 302 error.  Reverting back to PHP 4.3.8 resolves the issue.

Using fopen() and fpassthru() only makes the issue worse.

We are using IIS 6 and the PHP ISAPI script engine.

Reproduce code:
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=".basename($filename).";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));


Expected result:
PHP 5 has an issue with sending large binary files.  This should be resolved.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-24 20:14 UTC] thomas at mbox371 dot swipnet dot se
latest apache2, Windows 2000 server,  php 5.0.0/5.0.1/5.0.2-cvs.. same problem with all these configurations. When streaming files > 5mb thru php there is timeouts. Also, it seems not to work to stream these files over a slower connections (0.5mbit) at all (stops after a few seconds) when it works better on a 100mbit lan.
 [2004-09-13 13:43 UTC] thomas at mbox371 dot swipnet dot se
the problem exists in php 4.3.8 as well.
 [2004-11-16 00:55 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Tue Oct 13 18:01:32 2015 UTC