#48084 [Opn->Fbk]: Zip becomes corrupt when using ZipArchive

From: Date: Mon, 27 Apr 2009 08:47:19 +0000
Subject: #48084 [Opn->Fbk]: Zip becomes corrupt when using ZipArchive
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-136351@lists.php.net to get a copy of this message
ID: 48084 Updated by: pajoye@php.net Reported By: darrenkarstens at googlemail dot com -Status: Open +Status: Feedback Bug Type: Output Control Operating System: Windows XP PHP Version: 5.2.9 -Assigned To: +Assigned To: pajoye New Comment: Please provide a link to the archive you use for this test. Previous Comments: ------------------------------------------------------------------------ [2009-04-27 08:46:17] darrenkarstens at googlemail dot com Description: ------------ When using the ZipArchive::renameIndex function to rename the files in a zip archive the zip becomes corrupt. I have tried several different zip files and they all become corrupt. Reproduce code: --------------- $client='TEST'; $zip = new ZipArchive(); if ($zip->open($targetpath,ZIPARCHIVE::OVERWRITE)===true) { // prefix all of the files with the clients name for($i = 0; $i < $zip->numFiles; $i++) { $zip->renameIndex($i,$client.$zip->getNameIndex($i)); } if (!$zip->close()) echo 'Failed to rename zip'; }else echo'Failed to open zip'; Expected result: ---------------- This should open an existing zip archieve from the path $targetpath and prefix all of the filenames of its files with the word 'TEST'. Actual result: -------------- The files do appear to get renamed when I open the finished archieve however I am unable to extract the files from the zip because they are corrupt. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48084&edit=1

« previous php.bugs (#136351) next »