Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Hide download URL
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Hide download URL

 Post Reply Post Reply
Author
brolinuk View Drop Down
Newbie
Newbie
Avatar

Joined: 24 October 2003
Location: United Kingdom
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote brolinuk Quote  Post ReplyReply Direct Link To This Post Topic: Hide download URL
    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

Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
brolinuk View Drop Down
Newbie
Newbie
Avatar

Joined: 24 October 2003
Location: United Kingdom
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote brolinuk Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Bluefrog View Drop Down
Senior Member
Senior Member


Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bluefrog Quote  Post ReplyReply Direct Link To This Post Posted: 04 November 2003 at 9:10am

As the other thread was closed...

Google 'ethereal' for more info.

Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post 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
%>

Edited by fernan82
FeRnAN
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.