References: Populating response

Source: Internet
Author: User
Response can put the file to the user can not reach the place, and then in the ASP file with BinaryRead, the method sent to the user, here is a function,
Const forreading=1
Const Tristatetrue=-1
Const file_transfer_size=16384
Function transferfile (path, mimetype)
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=" &file_name
Response.AddHeader "Content-length", objfile.size
Do as 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 MimeType, sucess
MimeType = "Application/x-msdownload"
File_path=server. MapPath ("software/" & file_name)
Success = Transferfile (File_path, MimeType)
%>






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.