A
Arguich811
I use a script to force the browser to save instead of displaying a
simple text file. I downloaded the script some time ago and I don't
remember where I got it from. Does anyone recognize this script and if
so, do you know the author of this script:
------------------------------------
<%
' Constants for Reading Text File
Const ForAppending = 8
Const ForReading = 1
Const ForWriting = 2
Const TristateFalse = 0
Const TristateMixed = -2
Const TristateTrue = -1
Const TristateUseDefault = -2
' File System Objects
Dim FSO
Dim TS
' Server File (this is the REAL name of the file)
Dim strFile: strFile = Server.MapPath("mybas1.bas")
' File to Save As (this is the name you want to tell the browser)
Dim strFileSave: strFileSave = "mybas2.bas"
' Tell Browser what the file name is, so it doesn't try to save as
"default.asp"
Call Response.AddHeader("Content-Disposition","attachment;
filename=""" & strFileSave & """")
' Write out content-type that will FORCE user to SAVE FILE.
' "image/gif" will display in browser
Response.ContentType = "bad/type"
' Initialize File System Object
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
' Open TextStream for Reading
Set TS = FSO.GetFile(strFile).OpenAsTextStream(ForReading,TristateTrue)
' TS.ReadAll DOES NOT WORK. Every Byte must be read and written
individually.
' I think you can read them in Chucks, but this was easier. If
you know how to
' Read chunks... go ahead, read chunks
Do While Not (TS.AtEndOfStream)
' Output MUST be BinaryWrite
Response.BinaryWrite(TS.Read(1))
Loop
' Cleanup, like all good programmers do.
TS.Close
Set TS = Nothing
Set FSO = Nothing
' You don't need this, but I like it.
Response.End
%>
-------------------------------
Many thanks in advance,
Arguich811
Arguich811*digitalice*com
simple text file. I downloaded the script some time ago and I don't
remember where I got it from. Does anyone recognize this script and if
so, do you know the author of this script:
------------------------------------
<%
' Constants for Reading Text File
Const ForAppending = 8
Const ForReading = 1
Const ForWriting = 2
Const TristateFalse = 0
Const TristateMixed = -2
Const TristateTrue = -1
Const TristateUseDefault = -2
' File System Objects
Dim FSO
Dim TS
' Server File (this is the REAL name of the file)
Dim strFile: strFile = Server.MapPath("mybas1.bas")
' File to Save As (this is the name you want to tell the browser)
Dim strFileSave: strFileSave = "mybas2.bas"
' Tell Browser what the file name is, so it doesn't try to save as
"default.asp"
Call Response.AddHeader("Content-Disposition","attachment;
filename=""" & strFileSave & """")
' Write out content-type that will FORCE user to SAVE FILE.
' "image/gif" will display in browser
Response.ContentType = "bad/type"
' Initialize File System Object
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
' Open TextStream for Reading
Set TS = FSO.GetFile(strFile).OpenAsTextStream(ForReading,TristateTrue)
' TS.ReadAll DOES NOT WORK. Every Byte must be read and written
individually.
' I think you can read them in Chucks, but this was easier. If
you know how to
' Read chunks... go ahead, read chunks
Do While Not (TS.AtEndOfStream)
' Output MUST be BinaryWrite
Response.BinaryWrite(TS.Read(1))
Loop
' Cleanup, like all good programmers do.
TS.Close
Set TS = Nothing
Set FSO = Nothing
' You don't need this, but I like it.
Response.End
%>
-------------------------------
Many thanks in advance,
Arguich811
Arguich811*digitalice*com