Print Page | Close Window

Hiding file address on a server in links

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=14125
Printed Date: 30 March 2026 at 11:30am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Hiding file address on a server in links
Posted By: moti
Subject: Hiding file address on a server in links
Date Posted: 06 March 2005 at 2:54am
Is there any code to hide a file link in server and user for downloading
that file only can see a link  to a page with query string

for example look at this link

http://arcade.reflexive.com/downloadgame.aspx?AID=165&CID=4381 - http://arcade.reflexive.com/downloadgame.aspx?AID=165&CID=4381
 
you never can see the direct link of file even you click on above link in Fire Fox (in Fire Fox you can see direct link of file during downloading )
the link that I found in firefox is this
 
http://reflexive02.com/download.php?CID=4381&CN=Reflexive.net&AN=Trivia+Machine&AID=165&FN=TriviaMachineSetup.exe&DCID=0&DID=17428493 - http://reflexive02.com/download.php?CID=4381&CN=Reflexive.net&AN=Trivia+Machine&AID=165& amp;FN=TriviaMachineSetup.exe&DCID=0&DID=17428493
 
it will not show any direct link of file
 
==
How we can make a code like that in ASP
 
 



Replies:
Posted By: Mart
Date Posted: 06 March 2005 at 3:43am
If you look closley at the URL it has
 
FN=TriviaMachineSetup.exe
 
that's whats pointing to the file.


Posted By: moti
Date Posted: 06 March 2005 at 5:26am
yes
I saw that but where is the link
its just file name
 


Posted By: WebWiz-Bruce
Date Posted: 06 March 2005 at 5:54am
It can be done using ADODB.Stream.

I do it for the download files on this site so that people can not link directly to the files and the download links uses a qurystring to get the file that only lasts 24 hours.

You can see how it works by downloading this forum software.

How it works is that you call an ASP file, you then use the ADODB.Stream object to stream the file to the user from whatever hidden location the file is in.

Here is a simple version of it:-


'Open FSO Object
Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")




'Set the stream object
Set objADOStream = server.createobject("ADODB.Stream")

'Open the streem oject
objADOStream.Open

'Set the stream object type to binary
objADOStream.Type = 1


'For ASP file
objADOStream.LoadFromFile  Server.MapPath("myfileToDownload.zip")

'Get the file length
Set fileObject = fsoObject.GetFile (Server.MapPath("myfileToDownload.zip"))
intFileLength = fileObject.size


'Char set
Response.CharSet = "UTF-8"

'Set the right response content type for zip file
Response.ContentType = "application/octet-stream"

'Set the name of the file to download
Response.AddHeader "Content-disposition", "attachment; filename=myfileToDownload.zip"

'File size
Response.AddHeader "Content-Length", intFileLength



'Send zip to browser
Do Until objADOStream.EOS

    'Make sure browser is connected
         If Response.IsClientConnected Then

             'Write the ado stream in small scable chunks
                  Response.BinaryWrite objADOStream.Read(100000)

              'If buffer is done empty
              If Response.Buffer Then
                &a mp;a mp;n bsp; Response.Flush
              End If
         Else
                  Exit Do
         End If
Loop



'Clean up
Set fsoObject = Nothing
Set fileObject = Nothing
objADOStream.Close
Set objADOStream=Nothing


As well as the location you can also change the name of the file before it is download.

The zip files for this site are actually stored with a .asp extension so even if someone did find the location of the file they can not directly download the file.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: moti
Date Posted: 06 March 2005 at 6:54pm
Hello Borg
Thanks a lot buddy
it works fine on your site
 
But I could not run it
I save above code in a file and changed files and locations
this is my code
 
=====
<%
'Open FSO Object
Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")

'Set the stream object
Set objADOStream = server.createobject("ADODB.Stream")
'Open the streem oject
objADOStream.Open
'Set the stream object type to binary
objADOStream.Type = 1

'For ASP file
objADOStream.LoadFromFile  Server.MapPath("uploads/myfile.asp")
'Get the file length
Set fileObject = fsoObject.GetFile (Server.MapPath("uploads/myfile.asp"))
intFileLength = fileObject.size

'Char set
Response.CharSet = "UTF-8"
'Set the right response content type for zip file
Response.ContentType = "application/octet-stream"
'Set the name of the file to download
Response.AddHeader "Content-disposition", "attachment; filename=005.zip"
'File size
Response.AddHeader "Content-Length", intFileLength
 
'Send zip to browser
Do Until objADOStream.EOS
    'Make sure browser is connected
         If Response.IsClientConnected Then
             'Write the ado stream in small scable chunks
            
    Response.BinaryWrite objADOStream.Read(100000)
              'If buffer is done empty
              If Response.Buffer Then  
                &a mp;a mp;n bsp; Response.Flush
              End If
         Else
                &nbs p; Exit Do
         End If
Loop

'Clean up
Set fsoObject = Nothing
Set fileObject = Nothing
objADOStream.Close
Set objADOStream=Nothing
%>
=====
 
I renamed my file to myfile.asp in uploads folder and in Response.AddHeader line I renamed it to 005.zip 

when I ran above code I get this error
===
 

Microsoft VBScript compilation error '800a0400'

Expected statement

downloader.asp, line 50

&a mp;a mp;n bsp; Response.Flush
^
===
 
I removed this codes

&a mp;a mp;n bsp;

and ran it again but now I just can see chunks unreadable codes in entire of my page
 
How can I use your code
Like your site for my files
 
 
Thanks a lot


Posted By: dj air
Date Posted: 06 March 2005 at 7:38pm
from having a quick look this part looks different compared to boRg's as he has set a .xip file name and you have set a .asp file name


'For ASP file
objADOStream.LoadFromFile  Server.MapPath("uploads/myfile.asp")
'Get the file length
Set fileObject = fsoObject.GetFile (Server.MapPath("uploads/myfile.asp"))
intFileLength = fileObject.size

'Char set
Response.CharSet = "UTF-8"
'Set the right response content type for zip file
Response.ContentType = "application/octet-stream"
'Set the name of the file to download
Response.AddHeader "Content-disposition", "attachment; filename=005.zip"
'File size


Posted By: moti
Date Posted: 07 March 2005 at 2:53am
no thats not my problem
its actual file name and it will save it as a ZIP file again

Confused


Posted By: moti
Date Posted: 07 March 2005 at 6:11am
Hey Borg thank you its working now
I am using this code
 
====
'Open FSO Object
Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")

'Set the stream object
Set objADOStream = server.createobject("ADODB.Stream")
'Open the streem oject
objADOStream.Open
'Set the stream object type to binary
objADOStream.Type = 1

objADOStream.LoadFromFile  Server.MapPath("uploads/myfile.asp")
'Get the file length
Set fileObject = fsoObject.GetFile (Server.MapPath("uploads/myfile.asp"))
intFileLength = fileObject.size
 
'Char set
Response.CharSet = "UTF-8"
 
'Response.ContentType = "image/gif"
Response.ContentType = "application/x-zip-compressed"
'Response.ContentType = "application/pdf"

Response.AddHeader "Content-disposition", "attachment; filename=00005.zip"
'File size
Response.AddHeader "Content-Length", intFileLength
 
'Send zip to browser
Response.BinaryWrite objADOStream.Read
'Flush the response object
Response.Flush

'Clean up
Set fsoObject = Nothing
Set fileObject = Nothing
objADOStream.Close
Set objADOStream=Nothing
====
 
But I have another problem when I add ZIP file its working fine but when I add another file types for ex  PDF  it will damage the file
yes I change contentType  to PDF but the same problem
 
when I use this code in an empty file it work fine and PDF file will work good but because I use this system in my forum I must include common.asp  in top of the page when I use this include file the problem will back
and all of files  will damage except zip files
 
What is in common.asp that is reason for damaging file when we download file via this script?
 
Help Me Borg
 
Thanks


Posted By: moti
Date Posted: 07 March 2005 at 10:51am
another problem
 
With this scripts the Resume not supported for downloads
and another thing is this download can`t be downloaded via a download manager like DAP
 
so is there any way to solve above problems
?
 


Posted By: Mart
Date Posted: 07 March 2005 at 11:16am
That's usually controlled by your web server, not asp as asp does not actually send the headers to the browser


Posted By: moti
Date Posted: 07 March 2005 at 11:47am

so there is not anyway?

but what about this
 
http://arcade.reflexive.com/downloadgame.aspx?AID=165&CID=4381 - http://arcade.reflexive.com/downloadgame.aspx?AID=165&CID=4381
 
this link support resume and can be downloaded via Download manager
 
??


Posted By: barnum64
Date Posted: 19 March 2005 at 10:56am
Please help me, I simply have to download a bunch of logfiles from a REMOTE WebSite in txt format when i launch a script. I use this code...
 
<%
ciclo=0
cicli=enddate1-startdate1+1
'Response.Write "<br>"
'Response.Write cicli
FileName = filtro + ".txt"
For ciclo = 0 to cicli
 
  strYear = Mid(startdate1, 7)
  strMonth = Mid(startdate1, 4, 2)
  strDay = Left(startdate1, 2)
  stringa = (strYear & strMonth & strDay)
  fileURL = " http://xxx.xxx.xxx/logs/ - http://xxx.xxx.xxx/logs/ " & stringa & ".txt"
  hdFileName = hdLocation+stringa+FileName
  Response.Buffer = True
  Set xmlHTTP = Server.CreateObject("Microsoft.XMLHTTP")
 
  xmlHTTP.open "GET", fileURL, False
  xmlHTTP.Send ""
  Response.Flush
 
  set myStream = CreateObject("ADODB.Stream")
  myStream.Open
  myStream.Type = 1
  myStream.Write xmlHTTP.ResponseBody
  myStream.Position = 0    'Posizione iniziale di stream
  
  set FSO = Createobject("Scripting.FileSystemObject")
  if fso.Fileexists(hdFileName) then Fso.DeleteFile hdFileName
  set FSO = Nothing
  myStream.SaveToFile hdFileName
  myStream.Close
  Set myStream = Nothing
  Set xmlHTTP = Nothing
  startdate1=startdate1+1
  Response.Write "<br>"
  Response.Write startdate1
next
Response.Flush
%>
 
...everything works fine but there is a simpler method to do it or to copy txt files from a remote webserver to local disk?



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