Bug #9278 [NEW]: Images files added with ZipArchive::addFile corrupt

From: Date: Wed, 08 Nov 2006 18:07:28 +0000
Subject: Bug #9278 [NEW]: Images files added with ZipArchive::addFile corrupt
Groups: php.pear.webmaster 
Request: Send a blank email to pear-webmaster+get-5406@lists.php.net to get a copy of this message
From: luc_azer at yahoo dot fr Operating system: XP PHP version: 5.2.0 RC4 Package: Web Site Bug Type: Bug Bug description: Images files added with ZipArchive::addFile corrupt Description: ------------ I want to add an image files (logo.gif) to a newly created and not yet existing zip-archive by using the method 'ZipArchive::addFile'. WinRAR 3.61 reports Diagnostic messages: CRC failed in logo.gif The file is corrupt Winzip 9.0: invalid compressed data to inflate. The result come from a modify version of the create.php example Reproduce code: --------------- <?php error_reporting(E_ALL); if (!extension_loaded('zip')) { dl('zip.so'); } $thisdir = dirname(__FILE__); unlink("./test112.zip"); $zip = new ZipArchive(); $filename = "./test112.zip"; if (!$zip->open($filename, ZIPARCHIVE::CREATE)) { exit("cannot open <$filename>\n"); } else { echo "file <$filename> OK\n"; } $zip->addFromString("testfilephp.txt" . time(), "#1 This is a test string added as testfilephp.txt.\n"); $zip->addFromString("testfilephp2.txt" . time(), "#2 This is a test string added as testfilephp2.txt.\n"); $zip->addFile($thisdir . "/logo.gif","/logo.gif"); echo "numfiles: " . $zip->numFiles . "\n"; echo "status:" . $zip->status . "\n"; $zip->close(); unset($zip); ?> Expected result: ---------------- I expected newly created zip-archive with the readable image inside. Actual result: -------------- Impossible to read the image inside the zip file. -- Edit bug report at http://pecl.php.net/bugs/bug.php?id=9278&edit=1 --

« previous php.pear.webmaster (#5406) next »