[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2008-11-06
Medium Priority
Last Modified: 2012-05-05
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.

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.
Question by:pixalax
  • 2
LVL 12

Accepted Solution

R_Harrison earned 2000 total points
ID: 22896470
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
TransferFile = True
Set objStream = Server.CreateObject("ADODB.Stream") 
objStream.Type = 1		
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
Set objStream = Nothing

Open in new window


Author Closing Comment

ID: 31513859
Thank you very much.

Author Comment

ID: 22896887
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.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question