Save the following: Download.htm
Save the following: Download.asp
<% @ language = VBScript%>
<%
Const forreading = 1
Const Tristatetrue = -1
Const file_transfer_size = 16384
Response.buffer = TRUE
Function Transferfile (Path, MimeType, FileName)
Dim objfilesystem, Objfile, Objstream
DIM CHAR
DIM SENT
Send = 0
TRANSFERFILE = True
Set objfilesystem = server.createObject ("scripting.filesystemObject")
Set objfile = objfilesystem.getfile (PATH)
Set objstream = objfile.openastextStream (Forreading, Tristatetrue)
Response.addheader "Content-Type", Mimetype
Response.addheader "Content-Disposition", "Attachment; FileName =" & FileName
Response.addheader "Content-Length", Objfile.Size
Do While Not Objstream.atendofstream
Char = Objstream.read (1)
Response.binarywrite (char)
Sent = SENT 1
IF (SENT MOD file_transfer_size) = 0 THEN
Response.flush
IF not response.isclientconnected then
TRANSFERFILE = FALSE
Exit do
END IF
END IF
Loop
Response.flush
IF not response.isclientconnected the transportfile = false
Objstream.close
Set objstream = Nothing
Set objfilesystem = Nothing
END FUNCTION
DIM PATH, MIMETYPE, Sucess, DownFileName
DownFileName = Request ("FileName")
Path = server.mappath (downfilename)
MimeType = "text / plain"
Sucess = transfertfile (path, mimetype, downfilename)
Response.end
%>