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
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);
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.