开发者

Error when reading block of a file in php

My code is :

$fileName = 'http://www.test.com/test.txt';
$fileRes = fopen($fileName,'rb');
fseek($fileRes, -100,  SEEK_END);
$content = fread($fileRes, 10);

It gives this error :

Warning: fseek() [function.fseek]: stream does not support seeking in /home/skrsoft/public_html/a.php on line 10开发者_运维问答

This error is returned for all files ! Why ?


You are opening HTTP stream and not a local file.

You cannot use fseek, but you can check the content-length header, if it is sent, and skip (with fread() but without assigning to $content) as many bytes as needed


You can't use fseek with fopen file pointers that use ftp:// or http:// move the file local before using fseek.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜