php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33012 fread/fopen error
Submitted: 2005-05-12 05:59 UTC Modified: 2005-05-12 18:30 UTC
From: justin at aofrozencity dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.3.11 OS: Windows 2003 Server
Private report: No CVE-ID: None
 [2005-05-12 05:59 UTC] justin at aofrozencity dot com
Description:
------------
I figured out why the problem is. I found out that fread/fopen doesn't read image file exactly and properly because I checked orginal image file code that isn't match the image file code which was from fread/fopen. 

Reproduce code:
---------------
// Output PNG Image
$file = fopen('images/tmp/'.$tmpname, 'rb');
$source = fread($file , filesize('images/tmp/'.$tmpname));
fclose($file);
header("Content-Type: image/png");
print($source);


Expected result:
----------------
"The image cannot be displayed, because it contains errors"


Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-12 08:01 UTC] tony2001@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.



 [2005-05-12 09:01 UTC] justin at aofrozencity dot com
I checked the image address (f182a80e96b6d4aa7be83a1a75e4672f.png).It is located at E:\vhosts\aofrozencity.net\httpdocs\images\image_system\security_image\images\tmp\). It is correct. 

test.php file is located at "E:\vhosts\aofrozencity.net\httpdocs\images\image_system\security_image\"

You can check the orginal image file (http://aofrozencity.net/images/image_system/bugs/f182a80e96b6d4aa7be83a1a75e4672f.png)
and image (http://aofrozencity.net/images/image_system/bugs/test_php.png
) which is created by php with fwrite/fread.

Between the orginal image file and php image source aren't same.

test.php source here
<?
// Output PNG Image
$file = fopen("images/tmp/f182a80e96b6d4aa7be83a1a75e4672f.png", "r");
$source = fread($file , filesize('images/tmp/f182a80e96b6d4aa7be83a1a75e4672f.png'));
fclose($file);
header("Content-Type: image/png");
print($source);
?>

Result:The image ?http://aofrozencity.net/images/image_system/security_image/test.php? cannot be displayed, because it contains errors.
 [2005-05-12 10:06 UTC] tony2001@php.net
Set magic_quotes_runtime = Off.
No bug here.
 [2005-05-12 17:16 UTC] justin at aofrozencity dot com
Thank you. It works now.
 [2005-05-12 18:30 UTC] tony2001@php.net
.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Aug 16 20:01:27 2024 UTC