Every time download link comes with the unique download key, i just add the unique_key
with the name of download.zip file and its working...
// $db_secret_key Random Unique Number
$zipname = $db_secret_key."_download.zip";
if( !extension_loaded('zip') ){
echo "<script>alert('Error: Please contact to the Server Administrator!');</script>";
exit;
}
$zip = new ZipArchive;
if( $zip->open($zipname, ZipArchive::CREATE) === TRUE ){
foreach( $files as $file ){
$zip->addFile( BASE_PATH.$file_path.'/'.$file, $file );
}
$zip->close();
// Force Download
header("Content-Type: application/zip");
header("Content-disposition: attachment; filename=$zipname");
header("Content-Length: ".filesize($zipname)."");
header("Pragma: no-cache");
header("Expires: 0");
readfile($zipname);
exit;
} else {
echo "<script>alert('Error: problem to create zip file!');</script>";
exit;
}