Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Hiding file address on a server in links
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Hiding file address on a server in links

 Post Reply Post Reply Page  12>
Author
moti View Drop Down
Groupie
Groupie


Joined: 07 September 2004
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote moti Quote  Post ReplyReply Direct Link To This Post Topic: Hiding file address on a server in links
    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
 
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
 
 
it will not show any direct link of file
 
==
How we can make a code like that in ASP
 
 
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
moti View Drop Down
Groupie
Groupie


Joined: 07 September 2004
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote moti Quote  Post ReplyReply Direct Link To This Post Posted: 06 March 2005 at 5:26am
yes
I saw that but where is the link
its just file name
 
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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.


Edited by -boRg- - 06 March 2005 at 5:57am
Back to Top
moti View Drop Down
Groupie
Groupie


Joined: 07 September 2004
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote moti Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
moti View Drop Down
Groupie
Groupie


Joined: 07 September 2004
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote moti Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
moti View Drop Down
Groupie
Groupie


Joined: 07 September 2004
Status: Offline
Points: 73
Post Options Post Options   Thanks (0) Thanks(0)   Quote moti Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply Page  12>

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.