The code:
<?php $local_id = $_GET['id'];
mysql_connect("localhost", "root", "") or die("Could not connect: " . mysql_error());
mysql_select_db("database");
$sql = mysql_query("SELECT * FROM `videos` WHERE `id` = ".$local_id." ");
while($row = mysql_fetch_array($sql)){$file = $row["file_url"];}
header("Expires: Mon, 20 Dec 1980 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Pragma: no-cache");
header("Content-Type: video/flv");
readfile($file); ?>
The file is a .flv one but it takes ~ 1 min. to load the video
What can i do to load it faster?
Is this code correct?
Do not use output buffering for transferring large files. php has to store the entire file in memory and wait till it’s completely read before giving it out to the client. Just removing the
ob_*lines should work.