If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Chit Chat > How to force a Download box in HTML

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-19-04, 10:42
Nima Nima is offline
Registered User
 
Join Date: Nov 2004
Posts: 1
Forcing a Download box in ASP

I have a list of hyperlinks to files and would like to have the download box appear when user clicks on file links(of any type) instead of the files opening right away.
The following code fails at the loadfile command. It gives error 500. Can someone please help?

Thank you in advance,
Nima

<%@ Language=VBScript %>

<%

Dim filePath
Dim fileName
Dim FStream


'Set the file and path
fileName = request.querystring("f")
filePath = "http://authoring.tbs-sct.gc.ca/emis-sigd/download/" & fileName

'Response.write(filePath)
'Response.End

'Create the header information
Response.ContentType = "application/asp-unknown"
Response.AddHeader "content-disposition","attachment; filename=" & fileName

'Create and configure the object
Set FStream = Server.CreateObject("ADODB.Stream")
FStream.Open()
FStream.Type = 1
FStream.LoadFromFile(filePath)

'Stream it to the client
Response.BinaryWrite FStream.Read()

'Cleanup
FStream.Close
Set FStream = Nothing

'Force the end
Response.End

%>

Last edited by Nima; 12-07-04 at 14:01.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On