Zip files in php

$filePath = '/path/to/store/zip/in/';
$zip = new ZipArchive();
$download = "{$filePath}";
$zip->open($download, ZipArchive::CREATE);
foreach (glob($filePath . "*.jpg") as $file) {
    #add it to the zip
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 =");
header('Content-Length: ' . filesize($download));

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.