note 96811 deleted from function.ziparchive-addemptydir by danbrown

From: Date: Fri, 19 Mar 2010 15:33:29 +0000
Subject: note 96811 deleted from function.ziparchive-addemptydir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-167218@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- <?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; } ?>

« previous php.notes (#167218) next »