|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19783 A big problem with fread() with PHP4.3.0
Submitted: 2002-10-06 14:14 UTC Modified: 2005-10-05 17:06 UTC
From: Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4CVS-2002-10-06 OS: WindowsNT/XP/2000/9x
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2002-10-06 14:14 UTC]
on some of my code I use the following:
echo fread($fd,filesize($filename)); 

It looks fread is limited to a certain value. I can't get more than a certain size. With bigs files, I dont get all of them but just a part so I had to use fgets.

Can someone check if something changed on the fread()'s function that would limit it?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-06 20:28 UTC]
This bug looks really important. 

I dont know if it is because of the new handling of streams but I just verified that its working with PHP4.2.3 and not wit h 4_3 latest.
 [2002-10-06 20:56 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
 [2002-10-13 08:52 UTC]
Reopened this bug.

readfile() on 4.0, 4.2.4-dev and latest CVS-snapshot (13-Oct-2002 03:27) won't work with large files in Windows.

        print fread($ptfp,4096);
won't work.

Files <100k work fine, larger don't.

This error is reproductive on various computers with different Windows-Systems and occurs while trying to pass through PDF-files.
 [2002-10-13 09:09 UTC]
Sorry, my previous submitted problem is not related to this bug. 

Please see Bug #19886.
 [2003-01-03 10:03 UTC] josh at trollprod dot com
I got a similar problem with :
apache  1.3.27 
PHP 4.2.3
Os : Win NT 4

I do :
$fp = @fopen($localfile, "rb");
while (!feof($fp)) {
fwrite($file2,fread($file1, filesize($localfile)));

The size are differents on some test file (not all)
When the probleme occured the dest file is all the time smaller than the source file ... 


 [2003-01-03 11:15 UTC]
You have a while(!feof) that does fwrite which is completly wrong. You should READ the whole file (with fread and !feof), then fwrite it.


Thank for your report.
 [2003-04-02 05:26 UTC] r dot prodana at release-it dot de
Sorry, you said just read the whole file. What should I do when the file is already bigger than the memory_limit?
What's wrong in the following code?

$fpWrite = @fopen($localfile, "wb");
$fpRead = @fopen($localfile, "rb");

while (!feof($fpRead)) {
fwrite($fpWrite, fread($fpRead, 1024));

 [2003-04-17 04:54 UTC] simopal6 at yahoo dot it
I have found a similar problem with a script of mine, but actually fread() stops reading if it finds the string '^Z' (without single quotes)..I've done a little file splitter in php, and when i open files like programs it often gives me this error...
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 19:01:31 2024 UTC