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 > Data Access, Manipulation & Batch Languages > ASP > problem streaming file in asp

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-24-03, 09:45
ephemeralz ephemeralz is offline
Registered User
 
Join Date: Dec 2003
Posts: 20
Red face problem streaming file in asp

I'm having trouble streaming the file in asp. For the filename, it's showing the URLEncode of the Server.Mappath and the filetype is showing blank. I have tried this and it works in one place and for some reason it's not working now. Any ideas?
Thanks!

<%

Dim email, filename

filename=request("f")
email = Request("e")

sFileType= Right(filename,4)

Select Case sFileType
Case ".asf"
sContentType = "video/x-ms-asf"
Case ".avi"
sContentType = "video/avi"
Case ".doc"
sContentType = "application/msword"
Case ".zip"
sContentType = "application/zip"
Case ".css"
sContentType = "text/css"
Case ".pdf"
sContentType = "application/pdf"
Case ".xls"
sContentType = "application/vnd.ms-excel"
Case ".gif"
sContentType = "image/gif"
Case ".jpg", "jpeg"
sContentType = "image/jpeg"
Case ".wav"
sContentType = "audio/wav"
Case ".mp3"
sContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
sContentType = "video/mpeg"
Case ".rtf"
sContentType = "application/rtf"
Case ".htm", "html"
sContentType = "text/html"
Case ".asp", ".asa"
sContentType = "text/asp"
Case Else
sContentType = "application/x-msdownload"
End Select

NameFile=Right(filename,Len(filename)-InstrRev(filename,"\"))


Response.ContentType = sContentType

Response.AddHeader "Content-Disposition", "attachment;filename=" & NameFile

Const adTypeBinary = 1
Dim strFilePath
strFilePath = filename

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath

Response.BinaryWrite objStream.Read

objStream.Close
Set objStream = Nothing
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On