Print Page | Close Window

Hide download URL

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6877
Printed Date: 31 March 2026 at 4:31pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Hide download URL
Posted By: brolinuk
Subject: Hide download URL
Date Posted: 31 October 2003 at 7:06am

As we could see in many web site. while we tried to download the file, we would not be able to see the original URL, but just the file name. I tried to some thing similar like this. I have got some sample code here.

set rs=server.CreateObject("ADODB.RecordSet")
rs.open "select file from downfile where downid="&request("id")&" and downno="&request("no"),conn,1,1
 if not rs.eof then
  fileurl = rs("file")
 else
  rs.close
  set rs=nothing
  conn.close
  set conn=nothing
  response.write error
  response.end
 end if
 rs.close
 rs.open "select hits,hy from down where id="&request("id"),conn,1,2
 if not rs.eof then
  hy=rs("hy")
  rs("hits")=rs("hits")+1
  rs.update
 else
  rs.close
  set rs=nothing
  conn.close
  set conn=nothing
  response.write error
  response.end
 end if
 rs.close
 response.redirect fileurl

As you have seen, the page will redirect to fileurl, which is the URL address contained in the database. I have visited the site which use this code and it works as I mentioned above, but dosen't work on my site. Is this a correct code or I should use some thing else? Thanks




Replies:
Posted By: fernan82
Date Posted: 31 October 2003 at 10:31am
First off you need to say what's wrong with code, exactly what error are you getting...

Second, that won't protect the location of the file, once the user is redirected s/he will see the location of the file on his/her browser's address bar.

To protect the location of a file you need to use the stream object, I have posted several times (with examples) about it so just do a search for it and all the forums... With the stream object you can even host your files outside the web root or password protect the folder where the files are and as long as the web server user has rights to the files you can get them thru a script.

-------------
FeRnAN
http://www.danasoft.com/">


Posted By: brolinuk
Date Posted: 01 November 2003 at 7:00pm
Thanks fernan82, but I couldn't find your previous message. would you mind to post it again. I realy appreciate it. thanks. The problem find for the code above is the same as you said: user will be redirect to the new address and they would be able to see the URL.


Posted By: Bluefrog
Date Posted: 04 November 2003 at 9:10am

As the other thread was closed...

Google 'ethereal' for more info.



-------------
http://renegademinds.com/" rel="nofollow - Renegade Minds - Guitar Software http://renegademinds.com/Default.aspx?tabid=65" rel="nofollow - Slow Down Music


Posted By: fernan82
Date Posted: 04 November 2003 at 9:58am
<%
Option Explicit

Dim objStream
Dim strFilename

strFilename = "/downloads/filename.zip"
strFilename = Server.MapPath(strFilename) 'Comment this if using physical path

Set objStream = Server.CreateObject("ADODB.Stream") 'Create stream object

objStream.Type = 1   'Set it to binary
objStream.Open     'Open It
objStream.loadFromFile(strFilename) 'Read the file

Response.ContentType = "application/unknown"   'Set content type
Response.addHeader "content-disposition", "attachment;filename=" & Chr(34) & strFilename & Chr(34) 'Send header

Response.BinaryWrite objStream.Read 'Send file

objStream.Close 'Close object
Set objStream = Nothing   'Relase it
%>

-------------
FeRnAN
http://www.danasoft.com/">



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net