Download with ASP *. ASP files

Source: Internet
Author: User
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


%>








Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.