1

I'm thinking about a concept of how can I serve file/video without exposing the real path/url. What I have in mind is something like a database table which is composed of a hash and equivalent url like this:

id: 1 hash: ABCDEF realurl: http://site.tld/folders/videos/myvideo.mp4

Then, the video links are hidden by php like this:

http://site.tld/stream.php?video=ABCDEF

so that whenever I call the above url, it serves the file from realurl in database without the realurl being exposed to viewer since they are streaming the file/video through the stream.php

Any help would be appreciated.

EDIT: Here's what I did so far, still can't make it work. I wonder if I'm on the right way.

<?php
 
        $video = $_GET['video'];
        $username = "username";
        $password = "xxxxxxxxxxx";
        $hostname = "localhost";
        $database = "stream";
 
        $dbhandle = mysql_connect($hostname, $username, $password)
 
        or die("Unable to connect to MySQL");
 
        $selected = mysql_select_db($database,$dbhandle)
 
        or die("Could not select $database");
 
        $path = mysql_query("SELECT `realurl` FROM `stream` WHERE `hash`=’$video")
 
        or die(mysql_error());
 
        readfile($path);
 
        mysql_close($dbhandle);
 
?>
  • http://stackoverflow.com/questions/4286677/show-image-using-file-get-contents may get your answer. – Daniel Feb 27 '15 at 08:22

1 Answers1

0

Your solution would work.

Assuming that your URLs will be permanent, make sure you backup your database so that in case of crash or data loss, you are able to re-point your dynamic URLs to the correct video files.

MegaAppBear
  • 1,220
  • 1
  • 9
  • 11