|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39506 Archive corrupt with ZipArchive::addFile method
Submitted: 2006-11-13 23:22 UTC Modified: 2011-08-19 12:24 UTC
From: hscheidegger at zumbach dot ch Assigned: pajoye (profile)
Status: Closed Package: Zip Related
PHP Version: 5.2.0 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
14 + 27 = ?
Subscribe to this entry?

 [2006-11-13 23:22 UTC] hscheidegger at zumbach dot ch
We use PHP 5.2 on Windows XP and Server 2003, not the CGI version.
We are running Apache 2 with php as module and php_zip.dll as extension declared in php.ini.
The following script produces a corrupt zip archive, depending the content of 'TestDoc1.txt':

$zip = new ZipArchive;
$res = $zip->open( '', ZipArchive::CREATE );
if ($res === TRUE) {
   $zip->addFile( 'TestDoc1.txt', 'entryname1.txt' );
   echo 'ok';
} else {
   echo 'failed';

Reproduce code:
zip archive ok with TestDoc1.txt:
<body bgcolor="#CED5E5">

This is some text, we have to fill the file with nonsense.

zip archive corrupt with TestDoc1.txt:
<body bgcolor="#CED5E5">
This is some text, we have to fill the file with nonsense.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-14 09:33 UTC]
Please try using this CVS snapshot:
For Windows:

 [2006-11-14 09:53 UTC] hscheidegger at zumbach dot ch
We have the same behaviour with the proposed CVS snapshot.
Do you need additional information?
 [2006-11-14 14:37 UTC]
Can you try your script using CLI?
 [2006-11-14 19:10 UTC] hscheidegger at zumbach dot ch
Yes I did and it works without error.
Now, how to get work the .dll version with Apache 2.2.3 on Windows XP?
 [2006-11-15 16:26 UTC]
Please try using this CVS snapshot:
For Windows:

I just commited a fix, it should fix it for all other SAPI (it works in CLI/CGI/Embed).
 [2006-11-15 18:00 UTC] hscheidegger at zumbach dot ch
Unfortunately there is still the same problem.
I'm using Apache2.2.3 and the related versions of php5apache2.dll and php5apache2_filter.dll;
Does this matter?
 [2006-11-15 19:18 UTC]
The snaps have not been yet updated. Please wait the _next_ one and try again :)
 [2006-11-16 13:13 UTC] hscheidegger at zumbach dot ch
The 'addFile()' method is now working in our environment.
Thanks for your help,
Regards, H-P Scheidegger
 [2006-11-17 18:42 UTC]
For the record here, it was not an addFile problem but the binary mode being ignored by the windows API. It is now forced  to binary using a lower level function.
 [2011-08-19 09:48 UTC] claudio dot baratti at gmail dot com
Sorry, I have the same problem with php version 5.2.8 and apache 2.2.11 on platform winxp. I cannot upgrade to 5.3 version. In this version whould I still have the problem? or it's has been fixed?
 [2011-08-19 10:01 UTC]
PHP 5.2 is not supported anymore. I don't remember when was 5.2.8 released. Pls 
compare the release date with the date of this commit, that should give you the 
 [2011-08-19 11:34 UTC] claudio dot baratti at gmail dot com
5.2.8. has been released on 08 December 2008, so in theory I shouldn't have this problem.
 [2011-08-19 11:37 UTC]
Open a new bug with a reproduce script and with the data you use to reproduce your 
problem. Please keep it small and with only the zip related information.
 [2011-08-19 12:11 UTC] claudio dot baratti at amps-llc dot com
hello, the problem was reported on, so i resolved it to download php_zip.dll of 5.2.6 php version. Thanks
 [2011-08-19 12:24 UTC]
It is not resolved.

Downloading a previous version and it works mean that the bug was reintroduced 

Please, (oh please!) try using a recent version. You do not have to install php to 
try it, simply download the latest version, uncompress it somewhere and try your 
code in the console.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Jan 29 14:03:34 2022 UTC