Disguise URL of downloadable file

J

JJ

Hi,
I am writing a cart in ASP selling downloadable files.
The files are stored on remote locations i.e.
http://www.thisfilestore.com/file1.zip

And have different extensions, i.e. they are not all zip files.
I would like to write a script which cann be called which will allow the
download of the file, without giving away the url.

Any Ideas/examples welcome!
Thanks in Advance
JJ
 
S

Steven Burn

#1. Place them OUTSIDE of the web root
#2. Place them OUTSIDE of the web root
#3. Place them OUTSIDE of the web root

Once outside of the web root, they cannot be downloaded directly and thus,
you could simply just call the file whenever you <whatever it is your
wanting to do>

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 
T

Tom Kaminski [MVP]

JJ said:
Hi,
I am writing a cart in ASP selling downloadable files.
The files are stored on remote locations i.e.
http://www.thisfilestore.com/file1.zip

And have different extensions, i.e. they are not all zip files.
I would like to write a script which cann be called which will allow the
download of the file, without giving away the url.

Any Ideas/examples welcome!

Store the files outside of the web root path (so they don't actually have a
URL) and use ADODB.Stream and Response.BinaryWrite to send them to the
client.

http://www.aspfaq.com/show.asp?id=2161
http://support.microsoft.com/?kbid=276488

--
Tom Kaminski IIS MVP
http://www.microsoft.com/windowsserver2003/community/centers/iis/
http://mvp.support.microsoft.com/
http://www.iisfaq.com/
http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
http://www.tryiis.com
 
S

Stuart Palmer

You need to create a page that processes the download. The path to the file
can be anywhere but you just give the querystring param just the file name
(or ID number) then do something like this (I think)

------------------------
<%
filename = server.mappath("") ' Fill in the filename e.g. test.pdf,

Response.Buffer = True

dim objFSO, objTS
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTS = objFSO.OpenTextFile(fileName)

sFileType= Right(fileName,4)
NameFile=Right(FileName,Len(FileName)-InstrRev(FileName,"\"))
Select Case strFileType
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".asp"
ContentType = "text/asp"
Case Else
'Handle All Other Files
ContentType = "application/octet-stream"
End Select
response.contenttype=ContentType
response.AddHeader "content-disposition", "inline; filename=" & NameFile

Do While Not objTS.AtEndOfStream
strChunk = objTS.Read(32)
strTmp = ""
For i = 1 to Len(strChunk)
strTmp = strTmp & ChrB(Asc(Mid(strChunk, i, 1)))
Next
Response.BinaryWrite strTmp
Response.Flush
Loop
objTS.Close
Set objTS = Nothing
Set objFSO = Nothing
%>
------------------

Found this by searching the web, by looking at it it _might_ be similar to
what you are after.
In the code you can state the dir where all your files live...but don't
state it in the QS.

Good luck
Stu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top