I have the following code that works fine on Windows with WinRAR and works fine on Mac. However, for some reason, when you open it using Windows Explorer by default, the zip code looks empty, and when you right-click and retrieve it, it says it's invalid. When the same one opens with winrar or on mac, all files are there. Any ideas?
$passcode = $_GET['passcode'];
$zip = new ZipArchive;
$download = 'download_files_'.$passcode.'.zip';
$zip->open($download, ZipArchive::CREATE);
foreach (glob("../dashboard/uploads/".$passcode."/*.jpg") as $file) {
$zip->addFile($file);
}
$zip->close();
header('Content-Type: application/zip');
header("Content-Disposition: attachment; filename = $download");
header('Content-Length: ' . filesize($download));
header("Location: $download");
source
share