Renaming archive entries doesnt work

From: Date: Thu, 30 Apr 2009 08:41:52 +0000
Subject: Renaming archive entries doesnt work
Groups: php.general 
Request: Send a blank email to php-general+get-292144@lists.php.net to get a copy of this message
Hi, I am trying to add a prefix to all of the entries in a zip file using the ZipArchive::renameIndex function which is corrupting the files when I try to extract them. I was wondering if anyone else has used this method successfully? Here is the code im using: $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'; This renames the files inside the zip but when I try and extract them the zip is corrupt.

« previous php.general (#292144) next »