Sending a FLV through PHP

Hello,

This script will work fine on my WAMP dev server but on the live Linux server I am getting 500 server errors.

The whole point of the script is to keep users from downloading the flv I send to a swf player. Below is my code.

.httaccess
AddType application/x-httpd-php .flv

index.php

[code]

<?php session_start(); ?> Untitled Document <?php $_SESSION['isFair'] = "Yes"; ?> [/code]

video.flv - Found this script here

[php]<?php
session_start();
if($_SESSION[‘isFair’] == “Yes”)
{
unset($_SESSION[‘isFair’]);
$filename = “flv/01.flv”;
header(‘Content-Type: video/x-flv’);
header(‘Length: ’ . filesize($filename));
header(‘Content-Disposition: attachment; filename="’.$filename.’"’);
$fd = fopen($filename, “r”);
while(!feof($fd))
{
echo fread($fd, filesize($filename));
flush();
}
fclose ($fd);
}

else
echo “Stealing is not allowed”;

?>[/php]

I checked my server log and it says
file has no execute permission: (video.flv) so I give it execute permission. Then I get the error
file is writable by others: (video.flv), I take away write permissions and I still get error 500 and “Premature end of script headers:” is put in the log.

Any help will be greatly appreciated.

Problem solved…it was because I was using AddType application/x-httpd-php .flv in the htaccess file.

I should have been using AddHandler application/x-httpd-php .flv

Sponsor our Newsletter | Privacy Policy | Terms of Service