#19783 [Com]: A big problem with fread() with PHP4.3.0

From: Date: Thu, 17 Apr 2003 09:54:27 +0000
Subject: #19783 [Com]: A big problem with fread() with PHP4.3.0
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-37800@lists.php.net to get a copy of this message
 ID:               19783
 Comment by:       simopal6 at yahoo dot it
 Reported By:      nicos@php.net
 Status:           Closed
 Bug Type:         Filesystem function related
 Operating System: WindowsNT/XP/2000/9x
 PHP Version:      4CVS-2002-10-06
 New Comment:

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...


Previous Comments:
------------------------------------------------------------------------

[2003-04-02 05:26:11] 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));
}

fclose($fpWrite);
fclose($fpRead);

------------------------------------------------------------------------

[2003-01-03 11:15:59] nicos@php.net

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.

Bogus.

Thank for your report.

------------------------------------------------------------------------

[2003-01-03 10:03:49] 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 ... 



			
						
		}
		
		

		fclose($fp);

------------------------------------------------------------------------

[2002-10-13 09:09:20] spic@php.net

Sorry, my previous submitted problem is not related to this bug. 

Please see Bug #19886.

------------------------------------------------------------------------

[2002-10-13 08:52:31] spic@php.net

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.

Even
$ptfp=fopen($ipoc_passthru_fn,"rb");
        while(!feof($ptfp))
        {
        print fread($ptfp,4096);
        }
        fclose($ptfp);
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.

------------------------------------------------------------------------

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/19783

-- 
Edit this bug report at http://bugs.php.net/?id=19783&edit=1



Thread (9 messages)

« previous php.bugs (#37800) next »