Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于在IIS上下载文件的PHP标头_Php_Iis - Fatal编程技术网

用于在IIS上下载文件的PHP标头

用于在IIS上下载文件的PHP标头,php,iis,Php,Iis,我有一个php脚本,它使用头标签将远程文件从CDN下载到用户的机器上。我这样做是为了掩盖文件来源的真实URL。这是我的代码,$file是文件的真实URL $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $file); curl_setopt($ch, CURLOPT_NOBODY, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0

我有一个php脚本,它使用头标签将远程文件从CDN下载到用户的机器上。我这样做是为了掩盖文件来源的真实URL。这是我的代码,$file是文件的真实URL

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $file);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_exec($ch);

$filesize = curl_getinfo($ch,CURLINFO_CONTENT_LENGTH_DOWNLOAD);
curl_close($ch);

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $filename);
header('Content-Transfer-Encoding: binary');

header('Content-Length: ' . $filesize);
ob_clean();
flush();
readfile($file);
exit;

我在linux机器上安装了这个,它运行得很好。我把它移到了运行IIS的windows设备上,现在我收到了很多关于下载中断和下载未完成的投诉。是我的代码、IIS还是我的php配置导致了这个问题?

所以我找到了问题所在。这是FastCGI上的一个设置。为了解决这个问题,我进入IIS管理器,点击服务器,然后打开“FastCGI设置”。对于其他经历过这种情况的人:


右键单击可执行文件并选择“编辑”,然后将“活动超时”设置从“600”(10分钟)更改为另一个允许下载完成的值(我输入“60000”)。对“请求超时”进行相同的更改。保存您的设置,您就可以开始了。

两个框上的php配置是否相同?如果文件太大或提取时间太长,您可能会检查
max\u execution\u time
。也可能会耗尽内存。这里有太多的可能性。@spenibus它是一个1.5GB的文件,最大执行时间设置为999999999,所以我认为这不是问题所在。我想IIS有日志,可能有线索在那里。另外:这是我的php.ini的副本,有太多的内容需要覆盖。查看服务器日志(iis和php)将是一个更好的起点。