【发布时间】:2018-05-30 01:11:28
【问题描述】:
所以我正在做一些 PHP Corss-Origin 处理和隧道。在远程服务器上,我有一个 PHP 编译一些文件,这可能需要一段时间,具体取决于请求的文件。在另一台服务器上,我执行以下操作:
$file = "http://".$remote."/remote.php?prj=".$getprj;
$filename = substr($file,strrpos($file,"/")+1);
$fp = fopen($file, "r") or die("DEAD");
if(!headers_sent())
{
// http://php.net/manual/en/function.header.php#86554
// header("Content-Disposition: attachment; filename=".$filename);
header("Content-Disposition: attachment; "
.sprintf('filename="%s"; ', rawurlencode($filename))
.sprintf("filename*=utf-8''%s", rawurlencode($filename)));
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");
// header("Content-Length: " . filesize($filename));
}
flush(); // this doesn't really matter.
while (!feof($fp))
{
echo fread($fp, 65536);
flush(); // this is essential for large downloads
}
fclose($fp);
当我提出一个请求时,几秒钟后它会为我提供下载。当我提出另一个请求时,稍长一点后它又出现上述错误。
Warning: fopen(http://that.remote.server/remote.php?prj=tnt3): failed to open stream: HTTP request failed! in /.../current.php on line 18 DEAD
我几乎怀疑超时,但无法set_time_limit 我无法确定这一点。我在这里有什么选择?
【问题讨论】:
标签: php cross-domain fopen