php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21904 fwrite writes corrupt pdf binary file
Submitted: 2003-01-27 11:15 UTC Modified: 2003-01-27 17:04 UTC
From: delay at pobox dot com Assigned:
Status: Not a bug Package: Apache2 related
PHP Version: 4.3.0 OS: Windows XP Professional (SP1)
Private report: No CVE-ID: None
 [2003-01-27 11:15 UTC] delay at pobox dot com
when using the fwrite with
php4apache2.dll module enabled.  It seems to write corrupt binary(PDF) files.  I was using it with the ROS class
http://www.ros.co.nz/pdf/ to write PDF files. 

When I changed the apache 2 server from using php4apache2.dll to just using the cgi php.exe it was able to write these files just fine with no corruption.  I think something may not be working properly in the dll as it pertains to the fwrite function.  

I am pretty sure the error did not involve the ROS library as I was able to output to the screen with no problems with that library using the php4apache2.dll or php.exe.  It was only when I tried to write it to a file with fwrite that the problem occured.  This is the code I used for writing the document in case you need that.

$fp = fopen($fdirandname,'w');
fwrite($fp,$pdfcode);
fclose($fp);

I was using Apache/2.0.43 Windows XP Professional with SP1 installed and PHP 4.3.0 (the binary install version from your website).

I hope this helps. If you need any further info please email.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-27 12:17 UTC] wez@php.net
You *must* include the 'b' flag to fopen under windows if you want to have binary safe files.

$fp = fopen($fdirandname,'wb');
fwrite($fp,$pdfcode);
fclose($fp);
 [2003-01-27 17:04 UTC] sniper@php.net
not a PHP bug..

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 21:01:29 2024 UTC