$zip = new ZipArchive();
$zipFileDir = "c:/src/";
$zipFileName = "test.zip";
$zip->open($zipFileDir.$zipFileName, ZIPARCHIVE::CREATE);
/* FROM FOLDER c:/files/ */
$zipIncludedFilesDir = "c:/files/";
chdir($zipIncludedFilesDir);
$zip->addFile("a.jpg");
$zip->addFile("b.jpg");
$zip->close();
if(file_exists($zipFileDir.$zipFileName)) {
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$zipFileName);
header('Content-Length: ' . filesize($zipFileDir.$zipFileName));
readfile($zipFileDir.$zipFileName);
unlink($zipFileDir.$zipFileName);
}
exit;
$zipFileDir = "c:/src/";
$zipFileName = "test.zip";
$zip->open($zipFileDir.$zipFileName, ZIPARCHIVE::CREATE);
/* FROM FOLDER c:/files/ */
$zipIncludedFilesDir = "c:/files/";
chdir($zipIncludedFilesDir);
$zip->addFile("a.jpg");
$zip->addFile("b.jpg");
$zip->close();
if(file_exists($zipFileDir.$zipFileName)) {
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$zipFileName);
header('Content-Length: ' . filesize($zipFileDir.$zipFileName));
readfile($zipFileDir.$zipFileName);
unlink($zipFileDir.$zipFileName);
}
exit;
No comments:
Post a Comment