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.
精彩评论