flv download script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
akronymn
Forum Newbie
Posts: 7
Joined: Wed Jul 02, 2008 12:31 pm

flv download script

Post by akronymn »

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:

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);
}
Any ideas are greatly appreciated! -A
Post Reply