May be. Try adding the content length header as well:
header('Content-length: '.filesize($filename));
If this still does not work, check for any output before readfile( echoor spaces before <?php). Check also that after ?>you have no spaces or just omit it ?>(this is not necessary if nothing happens after that).
As Bruno mentioned, to support streaming you also need to obey the header Range. Here's a simplified example that only considers the left border:
if (empty($_SERVER["HTTP_RANGE"])) {
}
else {
preg_match("/^bytes=(\d+)-/i",$_SERVER["HTTP_RANGE"], $matches);
$offset = (int) $matches[1];
if ($offset < $filesize && $offset >= 0) {
if (@fseek($fp, $offset, SEEK_SET) != 0)
die("err");
header("HTTP/1.1 206 Partial Content");
header("Content-Range: bytes $offset-".($filesize - 1)."/$filesize");
}
else {
header("HTTP/1.1 416 Requested Range Not Satisfiable");
die();
}
}
source
share