|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 08:00:01 2025 UTC |
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)..$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 :(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> --------------------------------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.