|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47324 still not working after trying most versions
Submitted: 2009-02-06 04:43 UTC Modified: 2009-08-19 07:44 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: kmteoh at hotmail dot com Assigned: pajoye (profile)
Status: Closed Package: Zip Related
PHP Version: 5.2.9RC1 OS: win32 only -w2k
Private report: No CVE-ID: None
 [2009-02-06 04:43 UTC] kmteoh at hotmail dot com
can't get the ziparchive to add files correctly. tried different version of php_zip.dll same thing happen, and it generates funny files. followed instructions in #46985, used php_zip.dll version,, all not work. it only work in cli but not browser (isapi). it generates files like and for me instead of actual i renamed to then tried to extract but crc error.

Reproduce code:
$zip = new ZipArchive;
if ($zip->open('') === TRUE) {
    $zip->addFile('index.txt', 'newname.txt');
    echo 'ok';
} else {
    echo 'failed';

Expected result:
should be able to open the with winzip or winrar easily

Actual result:
crc error.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-06 08:29 UTC]
Please try using this CVS snapshot:
For Windows:

 [2009-02-06 08:30 UTC]
And be sure to actually use the correct extension dir.
 [2009-02-09 04:53 UTC] kmteoh at hotmail dot com
extension dir is definitely correct. the same script worked in cli but not browser (isapi). tried
 still no luck. i ended up using system() with external rar.exe and unrar.exe to do the job which is perfect. though certain system setup will not allow system() or exec() due to permission settings, which is why i am keen to have my product coded with php internal lib rather than using external tools.
 [2009-02-25 14:55 UTC]
please provide a link to the file you are adding.

Also the windows files are in
 [2009-02-25 15:00 UTC]
Other question, are you sure you are creating a fresh new archive and not opening an already corrupted archive?


if ($zip->open('', ZIPARCHIVE::CREATE) === TRUE)... (create a new one but does not overwrite an existing archive)


if ($zip->open('', ZIPARCHIVE::OVERWRITE) === TRUE)..
 [2009-03-01 22:36 UTC] kmteoh at hotmail dot com
i have tried CREATE and OVERWRITE options. both don't work. this is the file of creating brand new zip file using isapi.

in the file you can also find 2 files with fileext 03252 which was generated upon the script runs.

found a good script from by Rochak Chauhan works pretty well, he was using crc32() gzcompress() to do the job. hope this help.
 [2009-03-02 15:46 UTC]
I need the script you use to create this archive AND the original files you add to the archives. To show me the corrupted archive is not enough.
 [2009-03-02 21:27 UTC] kmteoh at hotmail dot com

here is the source code. the script i was using are all from anyway
 [2009-03-02 21:33 UTC]
Where are the files that you are actually adding to the archive?

All I see is a normal script and nothing but tempory (and corrupted) files created by the zip extensions, for example

Or are you trying to create in the \testscript\ directory using the content of \testscript\? That would be bad :)
 [2009-03-02 21:39 UTC] kmteoh at hotmail dot com
"Or are you trying to create in the \testscript\ directory using
the content of \testscript\? That would be bad :)"

i was actually trying to create new zip file in the folder i store my source file and source code (i was treating the zip.php is the file i want to add into archive) is that what causing all problem?
 [2009-03-02 21:46 UTC]
Yes, as it tries to add the temporary files as well (recursive additions so to say).

Can you try to create the archive in a complete different path:


and add the content of


for example.
 [2009-03-02 22:15 UTC] kmteoh at hotmail dot com
$path = 'C:\\inetpub\\wwwroot\\teohm\\gus\\';  //files to add in archive

$file = 'C:\\inetpub\\wwwroot\\teohm\\';  //target

$zip = new ZipArchive();

if (($zip->open($file, ZipArchive::CREATE)) === TRUE) {
	archive($path, null);  //same function as previous attachment


i see and in "C:\\inetpub\\wwwroot\\teohm\\"

still not working :(
 [2009-03-02 22:45 UTC]
ok, I still need the files you are adding to debug this problem. But it works here, IIS5/6/7 ISAPI or FastCGI.

 [2009-03-28 15:03 UTC] ivan3k-sc1 at yahoo dot com dot ar
I have the same problem trying to add a file, no mather its location.
Other files are ok.

this is the content of the file


<?$db = Db::getDbConnection();?>
Probando Conexi?n a BD: <?=($db->IsConnected() ? "OK" : "ERROR");?>

 [2009-03-28 15:51 UTC]
I've really no idea yet what's wrong. We have made some bug fixes lately, can you try again a 5.2/5.3 snapshot please?
 [2009-04-05 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-08-19 07:22 UTC] jw328 at gmail dot com
Exactly the same issue - I suspect its environment related. Mine is:
IIS6, Win2003, Isapi from 5.2.8.

Have tried php_zip.dll from 5.2.8 and 5.2.10 - both are v1.8.11 and siplay the same behaviour. Same issue looks as though its been occurring since 2006.

Couldn't get simpler code to reproduce (invoked from browser):

  $zip = new ZipArchive();
  $filename = "./";
  if (!$zip->open($filename, ZIPARCHIVE::CREATE)) {
  	exit("cannot open <$filename>\n");
  } else {
  	echo "file <$filename> OK\n";
  $zip->addFromString("ma.txt", "0123456789");

Having wasted the day on this I will use another library/exe.
 [2009-08-19 07:44 UTC]
Keep waste days if you don't use recent versions.

The bug has been fixed month ago.
 [2010-08-26 21:37 UTC] selosindis at gmail dot com
I noticed this bug was closed a long time ago, yet the examples from 
(listed here) are still not working.

There was no actual resolution posted here (that I could see), so if it is in 
fact fixed, could you please explain the process to get it working?

I'm running php 5.2.9 and the latest version of ZipArchive.

The files always end up with "" or something similar.

Thanks for your help!

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 01 17:03:35 2021 UTC