Download the following Save as: Download.htm
<a href=download.asp?filename=download.asp>guid.asp</a>
the following save as: 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, 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 Then transferfile = 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 = transferfile (path, mimetype,downfilename)
Response.End
%>