由Apache和PHP发送文件虚拟()函数HTTP_RANGE支持 [英] Sending files by Apache and PHP virtual() function with HTTP_RANGE support
问题描述
我使用PHP函数虚拟()由Apache 2.2的发送文件(它比<更快HREF =http://php.net/readfile相对=nofollow> ReadFile的()),我可以检查用户访问权限。
I'm using PHP function virtual() for sending files by Apache 2.2 (it works faster than readfile()) and I can check user access permissions.
但是,有什么办法可以增加连续下载支持,HTTP_RANGE?
But is there any way to add continuous download support, with HTTP_RANGE?
我已经试过这样的事情
if(isset($_SERVER['HTTP_RANGE'])) {
list($a, $range)=explode("=",$_SERVER['HTTP_RANGE']);
str_replace($range, "-", $range);
$size2=$size-1;
$new_length=$size-$range;
header("HTTP/1.1 206 Partial Content");
header("Content-Length: $new_length");
header("Content-Range: bytes $range$size2/$size");
apache_setenv('HTTP_RANGE', $_SERVER['HTTP_RANGE']);
} else {
$size2=$size-1;
header("Content-Range: bytes 0-$size2/$size");
header("Content-Length: ".$size);
}
所以Web的客户端被下载的文件一样,如果HTTP_RANGE工作,但在实际的Apache只是将始终是相同的文件范围,如:如果客户问4000-6000字节,阿帕奇发送0-2000等,使文件被打破。
So web-client was downloaded files like if HTTP_RANGE works, but in real Apache just sends always the same file-ranges like: if client ask 4000-6000 bytes, Apache sends 0-2000 and etc, so files was broken.
我觉得有某种方式使用apache_setenv做到这一点,但可以在谷歌没有找到任何建议。
I think that there is some way to do it using apache_setenv, but can't find in Google any suggestion about that.
推荐答案
尝试使用xfilesend模块的Apache。
Try to use xfilesend module for Apache.
这篇关于由Apache和PHP发送文件虚拟()函数HTTP_RANGE支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!