0

I put my videos on my Shared web host and user can direct download all files. but I want to hide my actual file paths and make time-limited download links. if files were on same server it is work fine. when I use this code :

return response()->download('/home2/alihoss1/domains/alihossein.ir/public_html/dl/video/MySql/Sql1.mp4');

i see this error :

is_file(): open_basedir restriction in effect. File(/home2/alihoss1/domains/alihossein.ir/public_html/dl/video/MySql/Sql1.mp4) is not within the allowed path(s): (/home2/alihosse/domains/alihossein.ir/:/tmp/:/usr/local/php-7.0/lib/php/)

What solution would you recommend ؟ videos and laravel Project are not same host.

Alihossein shahabi
  • 4,034
  • 2
  • 33
  • 53
  • Possible duplicate of [open\_basedir restriction in effect. File(/) is not within the allowed path(s):](http://stackoverflow.com/questions/1846882/open-basedir-restriction-in-effect-file-is-not-within-the-allowed-paths) – user1669496 Nov 16 '16 at 13:38

1 Answers1

0

You could use something like file_get_contents() to get the file from the other server. This would lead to unneccessary traffic though because server 1 would download the file from server 2. That applies also to scp etc.

You should think about encryption:

$hash = encrypt([
    'valid_to' => strtotime('+30 minutes'),
    'file_path' => '/home2/alihoss1/domains/alihossein.ir/public_html/dl/video/MySql/Sql1.mp4'
]);

return redirect('http://server2.example/download/hash/' . urlencode($hash));

You then need to decrypt this on the second server with the same key. If you do not have laravel installed there, you can implement your own decrypting functionality (see: laravel openssl encryption).

sleepless
  • 1,769
  • 1
  • 22
  • 33