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) { if( file_exists( $file_path . $files)) { $tmp = explode( "/", $files); $localname = array_pop( $tmp); $zip->addFile( $file_path . $files, $localname); } else { die( "File not found."); } } #echo "numfiles: " . $zip->numFiles . "\n"; #echo "status:" . $zip->status . "\n"; $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; } session_start(); settype( $_SESSION['downloadbox'], "array"); foreach( $_SESSION['downloadbox'] as $key=>$value) { /* $tmp = explode( "/", $value['filename']); $tmpfilename = array_pop( $tmp); $filearray[] = $tmpfilename; */ $filearray[] = $value['filename']; } zipFilesAndDownload( $filearray, "dombergkoesters_". date("YmdHis") .".zip", $_SERVER['DOCUMENT_ROOT'] ."/"); ?>