Hello to you all
I'm trying to put the following asp
<%@language = VBScript%>
<%
Response.Buffer = True
FilePath = "C:\Inetpub\
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
%>
so i can download the file from the browser.The file path is correct.
The above code is in a file named downloadxml.asp
The page which calls the downloadxml.asp is downloadcenter.asp and contains the following link
<a href="downloadxml.asp">
When i run it i get
Error Type:
ADODB.Stream (0x800A0BBA)
File could not be opened.
I cannot explain what is going on.
Any ideas or suggestions???
I'm trying to put the following asp
<%@language = VBScript%>
<%
Response.Buffer = True
FilePath = "C:\Inetpub\
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
%>
so i can download the file from the browser.The file path is correct.
The above code is in a file named downloadxml.asp
The page which calls the downloadxml.asp is downloadcenter.asp and contains the following link
<a href="downloadxml.asp">
When i run it i get
Error Type:
ADODB.Stream (0x800A0BBA)
File could not be opened.
I cannot explain what is going on.
Any ideas or suggestions???