<?php
$filePath = '/path/to/store/zip/in/';
$zip = new ZipArchive();
$download = "{$filePath}download.zip";
$zip->open($download, ZipArchive::CREATE);
foreach (glob($filePath . "*.jpg") as $file) {
#add it to the zip
$zip->addFile($file);
}
$zip->close();
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header('Content-Type: application/zip');
header("Content-Disposition: attachment; filename = download.zip");
header('Content-Length: ' . filesize($download));
readfile($download);Â
Related