开发者

PHP Download resume with hidden url link for large file

开发者 https://www.devze.com 2023-02-10 03:46 出处:网络
I\'m sorry to bother you with my issues, but i\'m facing a a problem that I have some trouble to fix.

I'm sorry to bother you with my issues, but i'm facing a a problem that I have some trouble to fix.

I have a website with a login restricted area.

Once the user is logged he can access to the files of my company (big file)

But to avoid the link to be spread all over the internet when a user want to download the file, located on an external url: he clicks on a url which will contain the name of the file crypted in md5 , which redirect on a php script which is going to generate in php, headers with the download using fsockopen.

However this does not support resume of download which is not very practical when we are d开发者_如何学运维ownloading somes files of 2 or 3 gb or when you are using a downloader.

How can I do to enable resume ? I have seen some php scripts using fread method , however i don't think it would be a good idea in my case, because for big files, it could make lag the server.. when you do a progressive fread on a 2gb files, good luck for the process when they are 30 poeple downloading the file in the meantime.


If you use fopen() and fseek() like this, you're essentially doing the same as any Webserver does to reply HTTP-RANGE requests.


You could make it so that it doesn't allow the file to be downloaded unless they are logged in.

So instead of providing them with a direct link to the file, they get a link like foo.com/download.php?myfile.ext

And the download.php would check the session before providing the user with the file download.

0

精彩评论

暂无评论...
验证码 换一张
取 消