在php中读取文件块时出错

在php中读取文件块时出错,php,Php,我的代码是: $fileName = 'http://www.test.com/test.txt'; $fileRes = fopen($fileName,'rb'); fseek($fileRes, -100, SEEK_END); $content = fread($fileRes, 10); 它给出了以下错误: Warning: fseek() [function.fseek]: stream does not support seeking in /home/skrsoft/publ

我的代码是:

$fileName = 'http://www.test.com/test.txt';
$fileRes = fopen($fileName,'rb');
fseek($fileRes, -100,  SEEK_END);
$content = fread($fileRes, 10);
它给出了以下错误:

Warning: fseek() [function.fseek]: stream does not support seeking in /home/skrsoft/public_html/a.php on line 10

所有文件都会返回此错误!为什么?

您打开的是HTTP流,而不是本地文件


不能使用fseek,但可以检查内容长度标题(如果已发送),并使用fread跳过,但不根据需要为$content分配尽可能多的字节

在使用fseek之前,不能将fseek与使用ftp://或http://将文件移动到本地的fopen文件指针一起使用。