Reputation: 1891
here is the content of my original zip:
If i run this code:
$zip = new ZipArchive;
if ($zip->open('update.zip') === TRUE) {
$zip->deleteName('include/mysql.php');
$zip->deleteName('install.php');
$zip->extractTo('./update/');
$zip->close();
unlink('./update.zip');
} else {
echo 'Fehler';
}
the files that are left are:
all others are deleted. Any idea why?
Upvotes: 0
Views: 694
Reputation: 369
Try to close the ZIP file after deleteName(), then open again to extract.
<?php
$zip = new ZipArchive;
if ($zip->open('update.zip') === TRUE) {
$zip->deleteName('include/mysql.php');
$zip->deleteName('install.php');
$zip->close();
$zip->open('update.zip');
$zip->extractTo('./update/');
$zip->close();
unlink('./update.zip');
} else {
echo 'Fehler';
}
?>
Upvotes: 3