Jump to content

header_location file serving question


optikalefx

Recommended Posts

im trying to play large files from under the webroot to an html5 video tag.  Nothing is working.

So i made a sym link to the folder and just header_location to the file.

 

and now when i tell html5 to play /video/play it works

 

but, when i open firebug net tab, i can see the requests are for the full URL to the video file, not the video/play that html5 is using.  Obviously because header_location will show the full path.

 

Is there any ways you guys think what im doing is possible? If not, how can i make it that the browser can play the video files, but the user can't go there directly in their browser?

Link to comment
https://forums.phpfreaks.com/topic/214690-header_location-file-serving-question/
Share on other sites

The files always need to be publicly available in order for them to be served to a browser.

 

What you can do however is write a php script which can serve the files, this php file (as well as hiding the actual file location) can then also be used to check your users are logged in or whatever before allowing the files to be served.

 

A simple script might look like....

 

serve.php

if (isset($_GET['movie'])) {
    $$movie = $_GET['movie'];
    $expires = 60 * 60 * 24 * 3;
    $exp_gmt = gmdate("D, d M Y H:i:s", time() + $expires )." GMT";
    $mod_gmt = gmdate("D, d M Y H:i:s", time() + (3600 * -5 * 24 * 365) )." GMT";

    @header("Content-type: $type");
    @header("Expires: {$exp_gmt}");
    @header("Last-Modified: {$mod_gmt}");
    @header("Cache-Control: public, max-age={$expires}");
    @header("Content-Length: {$size}");
    @readfile('/fule/path/to/movies/' . $movie);
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.