response可以把文件放到用户不能到达的地方,然后在asp文件中用binaryread,的方法发给用户,这里有一个函数,
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 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 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)
%>
引用:填充Response
80酷酷网 80kuku.com