Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata
$zipname = "$variable.zip";
$zip = new ZipArchive();
$tmp_file = tempnam('.','');
$zip->open($tmp_file, ZipArchive::CREATE);
 
foreach ($files as $file) {
	$download_file = file_get_contents($file);
	$zip->addFromString(basename($file),$download_file);
}
 
$zip->close();
header('Content-disposition: attachment; filename='.$zipname);
header('Content-type: application/zip');
readfile($tmp_file);
unlink($tmp_file);
  • No labels

1 Comment