我有一个可恢复的下载php脚本。
它在Apache服务器上运行正常但在IIS 7(我的客户端当前使用)
上没有IIS的问题是:
下载文件时,同一站点的其他页面将冻结。 (有时甚至会显示500服务器错误) (Apache服务器上的相同脚本不会出现同样的问题)
如果我关闭可恢复支持,问题就会失败 (即使在下载管理器上下载也会冻结查看同一站点的所有浏览器)
这让我相信IIS需要一些配置吗?还是php.ini?
到目前为止,谷歌没有运气,任何帮助都会感激不尽 并且..是的,我可以访问IIS和php.ini 是的。我已经在IIS上设置了最大连接时间(大文件传输需要)
这个脚本是.. (任何人都来到这里并喜欢使用此脚本在IIS上进行大文件传输请阅读 - > php on IIS 7>> FastCGI超时设置<<)
$filename="test.flv";
$filepath="zekkai.flv";
//set mime
$mime_type="";
$known_mime_types=array(
"flv" => "video/x-flv",
"mp4" => "video/mp4",
"mov" => "video/quicktime",
"avi" => "video/x-msvideo",
"wmv" => " video/x-ms-wmv "
);
if($mime_type==''){
$file_extension = strtolower(substr(strrchr($filepath,"."),1));
if(array_key_exists($file_extension, $known_mime_types)){
$mime_type=$known_mime_types[$file_extension];
} else {
$mime_type="application/force-download";
};
};
header("Connection: Keep-Alive");
header("Keep-Alive: timeout=65000");
$fsize=filesize($filepath);
set_time_limit(0);
//turn off buffer
ob_end_clean();
if(ini_get('zlib.output_compression'))
ini_set('zlib.output_compression', 'Off');
header("Content-Description: File Transfer");
header("Content-type: ".$mime_type);
header("Content-Disposition: attachment; filename=\"".$filename."\"");
header("Content-Transfer-Encoding: binary");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Accept-Ranges: bytes');
header("Cache-control: public");
header('Pragma: public');
header("Expires: 0");
// resumable support..
if(isset($_SERVER['HTTP_RANGE'])){
// delete this part to turnoff resumable support
list($a, $range) = explode("=",$_SERVER['HTTP_RANGE'],2);
list($range) = explode(",",$range,2);
list($range, $range_end) = explode("-", $range);
$range=intval($range);
if(!$range_end) {
$range_end=$fsize-1;
} else {
$range_end=intval($range_end);
}
$new_length = $range_end-$range+1;
header("HTTP/1.1 206 Partial Content");
header("Content-Length: $new_length");
header("Content-Range: bytes $range-$range_end/$fsize");
// resumable support end
} else {
$new_length=$fsize;
header("Content-Length: ".$fsize);
}
/* output the file itself */
$chunksize = 3*(1024*1024); //you may want to change this
$bytes_send = 0;
if ($Source_File = fopen($filepath, 'rb')){
if(isset($_SERVER['HTTP_RANGE'])){
fseek($Source_File, $range);
}
while(!feof($Source_File) && (!connection_aborted()) && ($bytes_send<$new_length) ) {
$buffer = fread($Source_File, $chunksize);
print($buffer); //echo($buffer); // is also possible
flush();
$bytes_send += strlen($buffer);
}
fclose($Source_File);
} else die('Error - can not open file.');
exit();
答案 0 :(得分:0)
请注意。 没有PHP脚本不受影响。 只有php页面受下载影响.. 所以我猜这个问题是针对fastcgi模块实现的?