我创建了通过浏览器下载zip文件的downlaod()方法,每个500-1500 MG。当我下载zip文件时,一切都很好,例如50 MB。问题只出在大文件上。
public function download($version) {
set_time_limit(0);
$file_name = $version . $this->extension;
$path = DOC_ROOT . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $this->folder_name . DIRECTORY_SEPARATOR . $file_name;
if(is_file($path) || connection_status() == 0)
{
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Content-Type: application/octet-stream");
header("Content-Length: ".(string)(filesize($path)));
header("Content-Disposition: inline; filename=$file_name");
header("Content-Transfer-Encoding: binary\n");
if ($file = fopen($path, 'rb')) {
while(!feof($file)) {
print fread($file,$this->transfer_speed);
flush();
}
fclose($file);
}
}
if(connection_status() !== CONNECTION_NORMAL)
{
echo "Connection aborted";
}
return((connection_status()==0) && !connection_aborted());
}