【发布时间】:2009-12-06 15:41:34
【问题描述】:
我想知道是否可以使用 PHP 和 exec 函数获取远程 flv 文件并使其“流式传输”。我的环境中有“卷曲”,所以我想要类似的东西:
exec ('curl http://myhosts.com/myflv.flv', $out);
print $out;
问题是 $out 作为数组返回;我想输出 curl 返回的“原始”流。
【问题讨论】:
我想知道是否可以使用 PHP 和 exec 函数获取远程 flv 文件并使其“流式传输”。我的环境中有“卷曲”,所以我想要类似的东西:
exec ('curl http://myhosts.com/myflv.flv', $out);
print $out;
问题是 $out 作为数组返回;我想输出 curl 返回的“原始”流。
【问题讨论】:
您应该能够为此使用fpassthru(),尽管将用户重定向到正确的 URL 可能会更好。
$fp = fopen('http://myhosts.com/myflv.flv', 'rb');
fpassthru($fp);
或重定向:
header('Location: http://myhosts.com/myflv.flv');
想想看,你应该还能用readfile()
readfile('http://myhosts.com/myflv.flv');
无论如何,如果您可以简单地重定向用户,请这样做。效率更高。
【讨论】:
Location 标头重定向仍然是首选方法,但我的理解是最大执行超时无法停止 PHP 函数的执行,因此它无法停止 readfile() 或 fpassthru()