Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
hidden url for download
Old 02-14-2006, 01:04 PM hidden url for download
Experienced Talker

Posts: 38
Trades: 0
Hello everyone ,

I'm coding a download system with ASP. I want to hide the URLs of the files and I want to allow only my members to download the files. I'm using these codes ;

Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set XFile = FSO.GetFile(Path)
Set TS=FSO.OpenTextFile(XFile)
Response.ContentType="application/unknown"
Response.AddHeader "Content-Disposition", "attachment; filename=" & FileName
Response.BinaryWrite TS.readall & ""
TS.Close
Set TS=Nothing
Set XFile=Nothing
Set FSO=Nothing


' FileName points the system path of the file.

But members download the files in a few seconds but there are some errors. For example 30mb. file downloads as a 1Kb.

I cannot understand reason of this error. What can I do or do you know another secure download system that permit unknown visitors to download files?

and the problems are occured just while downloading the video files (asf,wmw,mpeg). there are no problem while downloadind zip files.
chippi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-14-2006, 03:59 PM Re: hidden url for download
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
It will be the use of opentextfile, ideally you should be using be using a stream object

Working bit from the download script I use. The filename in this is constructed from the file path of the document calling the sub
Code:
Sub DownloadFile(strPath)
  Dim strAbsFile
  Dim strFileExtension
  Dim objFSO
  Dim objFile
  Dim objStream
  dim strFileName
  dim FileName
  
  ' set absolute file location
  strAbsFile = Server.MapPath(strPath)
'  response.write strAbsFile
  ' create FSO object to check if file exists and get properties
  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
  ' check to see if the file exists
  If objFSO.FileExists(strAbsFile) Then
    Set objFile = objFSO.GetFile(strAbsFile)
      Response.Clear
 	  FileName = split(objFile.name,".")
	  strFileName = GetPagePath() & "." & FileName(ubound(FileName)) ' right(objFile.Name,instrrev(objFile.Name,".") - 1)'& GetSubjectFolder()
      Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName ' objFile.Name
      Response.AddHeader "Content-Length", objFile.Size
      Response.ContentType = "application/octet-stream"
      Set objStream = Server.CreateObject("ADODB.Stream")
        objStream.Open
        '-- set as binary
        objStream.Type = 1
        Response.CharSet = "UTF-8"
        '-- load into the stream the file
        objStream.LoadFromFile(strAbsFile)
        '-- send the stream in the response
        Response.BinaryWrite(objStream.Read)
        objStream.Close
      Set objStream = Nothing
    Set objFile = Nothing
  Else  'objFSO.FileExists(strAbsFile)
    Response.Clear
    Response.Write("No such file exists.")
  End If
  Set objFSO = Nothing
End Sub
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to hidden url for download
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.18510 seconds with 12 queries