我有一个下载大文件的下载脚本(通常超过2GB,有时超过10GB)。下载似乎随机失败。
注意:我正在使用iis
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
$filename = 'https://downloadurl.com/SAS9_4W64.zip';
$head = array_change_key_case(get_headers("https://downloadurl.com/SAS9.3TS132bit.zip", TRUE));
$extension = fileexten($filename);
$fakename = 'SAS9.3TS132bitz';
if(($filename!= false)&&($fakename!=false&& @fopen('https://downloadurl.com/SAS9.3TS132bit.zip','r')==true)){
$mime = contenttype($extension);
set_time_limit(0);
header('Accept-Ranges: bytes');
header("Content-Type:".$mime);
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Disposition: attachment;filename='.$fakename.'.'.$extension);
header('Expires: 0');
header("Content-Transfer-Encoding: binary");
ob_clean();
ob_end_clean();
@readfile($filename);
session_write_close();
}