I am using the following code but there appears to be warning with fseek and returns -1 instead of 0.
$file = fopen("http://www.example.com/public_html/data/video/temp.mov", "r") or exit("unable to open file");
fseek($file, -128, SEEK_END);
The file gets opened definately but fseek doesn’t work. Is there some other method to read video from server?
Following is the error message
Warning: filesize() [function.filesize]: stat failed for
Warning: fseek() [function.fseek]: stream does not support seeking in
It must be some platform dependant problem. Try this code:
HTTP wrapper does not support seeking. If you want to seek in a remote file thru HTTP you need to get the size of the file. One possible way is to interpret a directory listing, or make a
HEADrequest. When you know the filesize you can use curl and Range like here.This is also a method to get remote file size.
How to download a file with cURL (This example loads the data into a PHP variable, use only if you want to process the data, If you just want to save it into an external file use CURLOPT_FILE instead of CURLOPT_RETURNTRANSFER):