Here's the code i'm using , problem i'm having is not getting the files in the browser or anything, it's coming up as download.asp for the filename on everything, or for say image types, right click and save as always is BMP format only and default name is untitled. is there any way to force filename? also MP3's and MPEGs for some reason are un-openable/readable.
thanks
DreX
thanks
DreX
Code:
<%
Response.Buffer = True
FilePath = Request("FullPath")
Response.Clear
Set Stream = Server.CreateObject("ADODB.Stream")
Set FS = CreateObject("scripting.FileSystemObject")
Set F = FS.GetFile(FilePath)
FileSize = F.Size
FileName = F.Name
FilePath = F.Path
Stream.Open
Stream.Type = 1
Stream.LoadFromFile FilePath
FileType = lcase(Right(FileName, 4))
ForceDownload = True
TextStream = False
Select Case FileType
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
ForceDownload = False
Case ".jpg", "jpeg",".jpe"
ContentType = "image/jpeg"
ForceDownload = False
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg",".mpe"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
ForceDownload = False
TextStream = True
Case ".txt", ".cfg"
ContentType = "text/txt"
ForceDownload = False
TextStream = True
Case ".asp"
ContentType = "text/asp"
ForceDownload = False
TextStream = True
Case Else
ContentType = "application/octet-stream"
End Select
If Not TextStream Then
If ForceDownload Then
Response.AddHeader "Content-Disposition", "attachment;filename=" & FileName
Else
Response.AddHeader "Content-Disposition", "filename=" & FileName
End If
Response.AddHeader "Content-Length", FileSize
Response.Charset = "UTF-8"
Response.ContentType = ContentType
Response.BinaryWrite Stream.Read
Response.Flush
Else
Set F = FS.OpenTextFile(FilePath, 1,-2)
%>
<html>
<body>
<xmp>
<%=F.ReadAll%>
</xmp>
</body>
</html>
<%
F.Close
End If
Set F = nothing
Set FS = nothing
Stream.Close
Set Stream = Nothing
%>