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