Error in using of file

When i use file_get_contents with $offset != -1 returns false The file i want to get from a URL is very large. Is it possible to use offset parameter with non local file?

The code that i use it:

 $content = file_get_contents($encodedurl,false,NULL,$offset,$blocksize);

The PHP documentation says:

Seeking (offset) is not supported with remote files. Attempting to seek on non-local files may work with small offsets, but this is unpredictable because it works on the buffered stream.

If your file is very large, then I think your best bet would be to write your own function which simulates a HTTP GET request to the resource. You can then read the file in on a buffered basis, that way you can store, say 16MB, chunks of the file onto disk, and once it has been fully downloaded you can always recombine this into one file. Or process it as chunks as required.

链接地址: http://www.djcxy.com/p/65594.html

上一篇: PHP强制下载远程文件而不读入内存

下一篇: 使用文件时出错