如何在php中压缩大文件(300MB)。我有问题,当我点击按钮,几秒后网页浏览器返回“此网站无法到达”,但我的压缩文件的过程仍然有效,并且创建zip后它将只在文件夹中,它将无法下载
答案 0 :(得分:0)
function createZip($zip, $dir, $listOFfiles)
{
if (ob_get_level()) {
ob_end_clean();
}
if (is_dir($dir)) {
foreach ($listOFfiles as $key => $fileName) {
if (is_file($dir . '/' . $fileName)) {
if ($fileName != '' && $fileName != '.' && $fileName != '..') {
// the problem is here. browser gets bad response
// because this process takes long time
$zip->addFile($dir . '/' . $fileName, $fileName);
flush();
}
}
}
return true;
}
return false;
}
?>