php.net |  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
Votes:2
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
Description:
------------
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 5.2.5.5, 5.2.8.8, 5.2.9.9 all not work. it only work in cli but not browser (isapi). it generates files like test.zip.b03252 and test.zip.a03252 for me instead of actual test.zip. i renamed to test.zip then tried to extract but crc error.

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


Expected result:
----------------
should be able to open the test.zip with winzip or winrar easily

Actual result:
--------------
crc error.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-06 08:29 UTC] pajoye@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-02-06 08:30 UTC] pajoye@php.net
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 http://snaps.php.net/php5.2-latest.tar.gz
 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] pajoye@php.net
please provide a link to the file you are adding.

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

Try:

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

or

if ($zip->open('test.zip', 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.
 
http://www.mingspc.com/mingspc/t.zip

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

found a good script from phpclasses.org by Rochak Chauhan works pretty well, he was using crc32() gzcompress() to do the job. hope this help.
 [2009-03-02 15:46 UTC] pajoye@php.net
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
http://www.mingspc.com/mingspc/source.zip

here is the source code. the script i was using are all from php.net anyway
 [2009-03-02 21:33 UTC] pajoye@php.net
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 t.zip.a03252.

Or are you trying to create t.zip 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 t.zip 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] pajoye@php.net
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:

c:\www\foo\t.zip

and add the content of

c:\www\bar\

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\\gus.zip';  //target

$zip = new ZipArchive();

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

}

i see gus.zip.a03932 and gus.zip.b03932 in "C:\\inetpub\\wwwroot\\teohm\\"

still not working :(
 [2009-03-02 22:45 UTC] pajoye@php.net
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
-------------------------------
<?
require_once("inc/core.php");
restore_error_handler();

?>

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

<hr>
--------------------------------
 [2009-03-28 15:51 UTC] pajoye@php.net
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):

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

Having wasted the day on this I will use another library/exe.
 [2009-08-19 07:44 UTC] pajoye@php.net
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 php.net 
(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 "zipName.zip.39u525" or something similar.

Thanks for your help!

~Scott
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Aug 07 13:01:24 2020 UTC