note 96811 modified in function.ziparchive-addemptydir by thiago
| From: | thiago@php.net | Date: | Thu, 18 Mar 2010 02:45:32 +0000 |
| Subject: | note 96811 modified in function.ziparchive-addemptydir by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-167158@lists.php.net to get a copy of this message | ||
<?php
/* creates a compressed zip file */
function zipFilesAndDownload($file_names,$archive_file_name,$file_path){
//create the object
$zip = new ZipArchive();
//create the file and throw the error if unsuccessful
if ($zip->open($archive_file_name, ZIPARCHIVE::CREATE ) !== TRUE) {
exit("cannot open <$archive_file_name>\n");
}
//add each files of $file_name array to archive
foreach($file_names as $files){
$zip->addFile($file_path.$files,$files);
}
$zip->close();
//then send the headers to foce download the zip file
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=$archive_file_name");
header("Pragma: no-cache");
header("Expires: 0");
readfile("$archive_file_name");
exit;
}
?>
--was--
/* creates a compressed zip file */
function zipFilesAndDownload($file_names,$archive_file_name,$file_path){
//create the object
$zip = new ZipArchive();
//create the file and throw the error if unsuccessful
if ($zip->open($archive_file_name, ZIPARCHIVE::CREATE ) !== TRUE) {
exit("cannot open <$archive_file_name>\n");
}
//add each files of $file_name array to archive
foreach($file_names as $files){
$zip->addFile($file_path.$files,$files);
}
$zip->close();
//then send the headers to foce download the zip file
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=$archive_file_name");
header("Pragma: no-cache");
header("Expires: 0");
readfile("$archive_file_name");
exit;
}
http://php.net/manual/en/function.ziparchive-addemptydir.php