PHP brings a class for ZIP file manipulation. It also allows the creation of directories with addEmptyDir() and the deletion of an entry with deleteName(). But the deletion does not work on directories (empty or not). Is there any way to delete empty folders in a ZIP file (prefered is buildin PHP functionality)?
You could always just extract it to a tmp directory, delete any empty directories with rmdir() and then zip it back up.
Another thing to check is permissions. Are you sure you have write permissions on the file you are trying to manipulate?
You need to append a / to directory names. So, something like this works:
<?php
$zip = new ZipArchive;
if ($zip->open('test.zip') === TRUE) {
$zip->deleteName('testDir/');
$zip->close();
}
?>
So, testDir/ versus testDir ....
Little note about the notion of directories. There is not such thing as a directory. For example: foo/a.txt and foo/b.txt are two entries, but there is no foo/ directory. However, it is possible to create an entry called foo/ to "emulate" a directory.
The delete method returning true while nothing has been removed looks like a bug, I asked Philip to open a new bug at http://bugs.php.net so I can fix it soonish.
Thanks!