How to create temporary download links with limited to 1 IP address?

Hello all,

I want to add download section to my website. There are already 3 kind of user groups.
2 paid, and 1 free.

 For free users I don't have problem but for paid users, I will add files to my server that's why all the links has to be hidden and if user is not logged in, can't download the paid link.

Simply;
1. Paid user will click download.
2. Script will create the download  links which will be expired in 24 hours  & 3 download attempts.
3. Paid download links (for paid members) should be locked to user's ip address to eliminate link sharing.
4. I would like to also hide the location of the file while user is downloading, if it is possible in the end it is all about it.

I will be glad if someone can help me out with that.
LVL 2
pixalaxAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

R_HarrisonCommented:
If you use the code below you can stream a file to the browser, the file does not need to be on your website only on the server (you may need to set permissions for the IUSER on the folder).  However as the folder does not need to be in your website it can't be accessed directly from a browser.

I would suggest setting up some sort of database to store and track the information regarding access to the files.  Then add code to verify the user is entitled to access to the top of the page below.

You may need to bear in mind that IP addresses can change?
<%
Dim filepath
filepath = "C:\SomeLocationOnYourServer\somefile.doc"
 
filename=right(filepath, len(filepath)-instrrev(filepath, "\"))
Response.Buffer = true
Response.Clear()
TransferFile = True
Set objStream = Server.CreateObject("ADODB.Stream") 
 
objStream.Type = 1		
objStream.Open 
objStream.LoadFromFile filepath
 
Response.AddHeader "Content-Disposition","attachment;filename=" & filename
Response.ContentType = MimeType
Response.AddHeader "Content-Length", objStream.Size
Response.ContentType = MimeType
Response.BinaryWrite objStream.Read
		  
objStream.Close
Set objStream = Nothing
%>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pixalaxAuthor Commented:
Thank you very much.
0
pixalaxAuthor Commented:
Thanks a lot for your explanations.

Since nobody is going to see or try to have access and also I can protect my files in that way, so there is no problem with that. The basic is the protect the files location.

Thank you very much, tested and it works.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.