I had tried to download multiple large files with the zip php extension but I wasn't successful, because the server has always timed out.
$revfiles = $_POST['file'];
if(empty($revfiles))
{
echo("You didn't select any file.");
}
else
{
$zip = new ZipArchive();
$filename = $_SERVER['DOCUMENT_ROOT'] . "/tmp/test70.zip";
if ($zip->open($filename, ZipArchive::CREATE)!==TRUE) {
exit("cannot open <$filename>\n");
}
$N = count($revfiles);
for($i=0; $i < $N; $i++)
{
if($zip->addFile($_SERVER['DOCUMENT_ROOT'] . "/" . $revfiles[$i], strrchr($revfiles[$i], "/"))!==TRUE){
//echo("ERROR");
}
}
$zip->close();
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=test70.zip");
header("Pragma: no-cache");
header("Expires: 0");
readfile("$filename");
exit;
}
[30-Dec-2015 12:32:17 Europe/Berlin] PHP Fatal error: Maximum execution time of 30 seconds exceeded in /.../file.php on line 37
After I had disabled the time limit for this script, I got this error:
[30-Dec-2015 16:38:29 Europe/Berlin] PHP Fatal error: Allowed memory size of 524288000 bytes exhausted (tried to allocate 660656128 bytes) in /.../file.php on line 43
Does somebody know another way to download multiple large files with php ?