rondog Posted August 31, 2010 Share Posted August 31, 2010 I have some FLV files above web root. I want to feed my flv player a php file and an ID. I need that php file to return an flv file basically. So if someone has firebug or something they wont see a video path, but instead see something like: fileserve.php?id=4679 I dont care if a logged in user go directly to that link and it prompts them with a download or whatever. I just want to avoid having a non logged in user do that. Quote Link to comment https://forums.phpfreaks.com/topic/212196-load-file-through-php/ Share on other sites More sharing options...
Alex Posted August 31, 2010 Share Posted August 31, 2010 Use readfile. Quote Link to comment https://forums.phpfreaks.com/topic/212196-load-file-through-php/#findComment-1105714 Share on other sites More sharing options...
rondog Posted August 31, 2010 Author Share Posted August 31, 2010 Ok that is working..I am seeing the video load in firebug. This is my code right now: <?php include("connect.php"); if ($_SESSION['loggedIn'] == true) { $id = $_GET['id']; $query = mysql_query("SELECT filename FROM video WHERE id = '$id'"); $row = mysql_fetch_array($query); header("Content-type: video/flv"); echo readfile("../../../armsmedia/videos/".$row['filename']); } else { echo "invalid action"; } ?> My video player is throwing this error: VideoError: 1005: Invalid xml: URL: "inc/fileserve.php?id=4679" No root node found; if url is for an flv it must have .flv extension and take no parameters at fl.video::SMILManager/http://www.adobe.com/2007/flash/flvplayback/internal::xmlLoadEventHandler() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete() I know this isnt a flash forum, but who knows, someone may know what is going on here. I think I am outputting the raw data in the php file and flash is seeing that and not a video file Quote Link to comment https://forums.phpfreaks.com/topic/212196-load-file-through-php/#findComment-1105718 Share on other sites More sharing options...
rondog Posted August 31, 2010 Author Share Posted August 31, 2010 also when I browse to the file, it does download and save to my desktop, however it is saving as fileserve.php, but if I rename it to a .flv extension, it is the actual file. Quote Link to comment https://forums.phpfreaks.com/topic/212196-load-file-through-php/#findComment-1105721 Share on other sites More sharing options...
rondog Posted August 31, 2010 Author Share Posted August 31, 2010 ok figured it out! fileserve.php: <?php include("connect.php"); if ($_SESSION['loggedIn'] == true) { $id = $_GET['id']; $query = mysql_query("SELECT filename FROM video WHERE id = '$id'"); $row = mysql_fetch_array($query); $filename = "../../../armsmedia/videos/".$row['filename']; header( 'Content-Description: File Transfer' ); header( 'Content-Type: application/octet-stream' ); header( 'Content-Disposition: attachment; filename='.basename( $filename ) ); header( 'Content-Transfer-Encoding: binary' ); header( 'Expires: 0' ); header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' ); header( 'Pragma: public' ); header( 'Content-Length: ' . filesize( $filename ) ); ob_clean(); flush(); readfile( $filename ); exit; } else { echo "invalid action"; } ?> The problem with the flash was, the path it needs has to be an flv extension and has to have no parameters which it obviously did. I made a rewrite rule thanks to http://dennisjaamann.com/blog/?tag=movie Options +FollowSymlinks RewriteEngine on RewriteRule ^videos/([^/]+).flv inc/fileserve.php?id=$1 [NC] So now rather than passing this path to my flv player: http://mysite.com/fileserve.php?id=4679, I pass: http://mysite.com/videos/4679.flv and it works! That link is also only accessible if you're logged in which is exactly what I was looking for! Quote Link to comment https://forums.phpfreaks.com/topic/212196-load-file-through-php/#findComment-1105740 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.