how to create an empty zip archve by php some thing like new -> zip archive
I use this code to return a zip file from an array of files to be zipped, if the array is empty, than it returns an empty zip archive, hope it helps.
function zipFiles($files){
// "UEsFBgAAAAAAAAAAAAAAAAAAAAAAAA==" is the base64 encoded content of an empty zip archive
if(count($files) == 0){
return base64_decode("UEsFBgAAAAAAAAAAAAAAAAAAAAAAAA==");
}
$zip = new ZipArchive();
... do your stuff
foreach($files as $file){
... do your stuff
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With