php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9024 fread can't read whole file
Submitted: 2001-01-31 05:19 UTC Modified: 2001-01-31 12:44 UTC
From: zionglau at yahoo dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.0.4pl1 OS: WinNT 4.0
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: zionglau at yahoo dot com
New email:
PHP Version: OS:

 

 [2001-01-31 05:19 UTC] zionglau at yahoo dot com
i'm using the following code to read and output a file:

$fp = fopen("a_file_here", "r");
// retreive the file content
while (!feof($fp)){
	set_time_limit(5);
	// retreive the file content
	$contents = fread($fp, 1024);
	// output the content
	echo ($contents);
	flush();
}

These codes is work fine in older version(php3),
but now it cannot read the file completly.
For example the file have 1024 byte, it only can read the first 300 byte.
Also it work fine with the TEXT file. This problem only happen when i try to read a binary file(e.g. gif/jepg).
it seem to be stop reading when the file have a eof char data but it is not really End Of File.

Moreover, i'm using Apache and running module mode, but it will work fine when running cgi mode.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-31 12:44 UTC] sniper@php.net
You need to read the manual page for fopen().

http://www.php.net/fopen

where it says that in some braindead systems (like Windows)
you have to use 'b' in the mode string to be able 
to read/write binary files.

ie. like this:
fopen("the_file", "rb");

--Jani

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 00:01:30 2024 UTC