最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
引用:填充Response
时间:2022-06-30 10:29:31 编辑:袖梨 来源:一聚教程网
可以把文件放到用户不能到达的地方,然后在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)
%>
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)
%>
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22