0) { while ($photoInfo = mysql_fetch_assoc($rezPhotoInfo)) { $obj['photo' . $photoInfo['sort_order']] = $photoInfo['photo']; } } $zip = new ZipArchive(); // Load zip library if ($obj['adres']) { $obj['adres'] = str_replace(".", "", $obj['adres']); $obj['adres'] = str_replace(",", "", $obj['adres']); $obj['adres'] = str_replace("/", "", $obj['adres']); $address_short = mb_substr($obj['adres'], 0, 50); $zip_name = trim($address_short)."_".$obj['id'].".zip"; } else { $zip_name = $obj['id']."_".time() . ".zip"; // Zip name } if ($zip->open($zip_name, ZIPARCHIVE::CREATE) !== TRUE) { // Opening zip file to load files echo 'Sorry ZIP creation failed at this time'; } $ph = 1; for ($i = 0; $i <= 40; $i++) { $path = $obj['photo' . $i]; if (stripos($obj['photo' . $i], "http://") === false && stripos($obj['photo' . $i], "https://") === false) { $obj['photo' . $i] = $_SERVER['DOCUMENT_ROOT'] . "/photos/" . $obj['photo' . $i]; } if ($path and @fopen($obj['photo' . $i], "r")) { $f1 = file_get_contents($obj['photo' . $i]); if (stripos($f1, " 5) { $filename = ".jpg"; } $zip->addFromString($ph.$filename, $f1); $ph++; } } } $zip->close(); if (file_exists($zip_name)) { // push to download the zip header('Content-type: application/zip'); header('Content-Disposition: attachment; filename="' . $zip_name . '"'); header('Cache-Control: max-age=0'); // If you're serving to IE 9, then the following may be needed header('Cache-Control: max-age=1'); // If you're serving to IE over SSL, then the following may be needed header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified header('Cache-Control: cache, must-revalidate'); // HTTP/1.1 header('Pragma: public'); // HTTP/1.0 readfile($zip_name); // remove zip file is exists in temp path unlink($zip_name); exit(); } } }