flv download script
Posted: Thu Jul 15, 2010 4:08 pm
I am writing a DAMS system and it needs to allow users to download flv files. With the help of google I'm getting really close. I can succesfully create the file at the target specified by the user and it is almost correct save for two little anomolies. The resulting file has a blank line at the beginning and the last two characters are getting left off ("G`"). If I manually edit these mistakes I can play the video fine, otherwise it does not work. Here's my download script:
Any ideas are greatly appreciated! -A
Code: Select all
if($fd = fopen($fullpath, "r")) {
$fsize = filesize($fullpath);
$path_parts = pathinfo($fullpath);
header("Content-Type: video/x-flv");
header("Content-Disposition: attachment; filename=\"".$path_parts['basename']."\"");
header("Content-length: $fsize");
header("Cache-control: private");
while(!feof($fd)) {
print(fread($fd, 8192));
}
fclose($fd);
}