I am trying to zip and download files from a folder named \"upload\". Zip file is downloading but I couldn\'t open (extract) it. I am getting an error like \"The archive is eith
$zip = new ZipArchive;
if ($zip->open('assets/myzip.zip', ZipArchive::CREATE)) {
$zip->addFile('folder/bootstrap.js', 'bootstrap.js');
$zip->addFile('folder/bootstrap.min.js', 'bootstrap.min.js');
$zip->close();
echo 'Archive created!';
header('Content-disposition: attachment; filename=files.zip');
header('Content-type: application/zip');
readfile($tmp_file);
} else {
echo 'Failed!';
}
I got this code to download files from a folder.