28,409
社区成员




<%
With Response
.Buffer = True
.Expires = 0
End With
On Error Resume Next
Dim oSF, oStream
Dim sFilePath
sFilePath = Results("path")
Results.Clear
Session.Abandon
Set oSF = CreateObject("newObjects.utilctls.SFMain")
If Not oSF.FileExists(sFilePath) Then
Set oSF = Nothing
Response.Write sFilePath & "不存在。"
Response.End
End If
Set oStream = oSF.OpenFile(sFilePath, &H00000040)
Set oSF = Nothing
If Not TransferFile(oStream, "application/octet-stream", getFileName(sFilePath)) Then
Set oStream = Nothing
Response.Write "传递文件失败。"
Response.End
End If
Set oStream = Nothing
Function TransferFile(ByRef oStream, sMimeType, sFilename)
Dim iChar, iSent, iSize
Dim c
Const FILE_TRANSFER_SIZE = 1024000'32768 '32k
iSent = 0
TransferFile = True
iSize = oStream.Size
c = 0
Do While c <= iSize
iChar = oStream.ReadBin(FILE_TRANSFER_SIZE)
c = c + FILE_TRANSFER_SIZE
With Response
.BinaryWrite(iChar)
iSent = iSent + FILE_TRANSFER_SIZE
If (iSent MOD FILE_TRANSFER_SIZE) = 0 Then
.Flush
If Not .IsClientConnected Then
TransferFile = False
Exit Do
End If
End If
End With
Loop
Response.Flush
If Not Response.IsClientConnected Then TransferFile = False
Set oStream = Nothing
End Function
Function getFileName(sPath)
Dim iPos
Dim s
iPos = InStrRev(sPath,"\")
s = Right(sPath,Len(sPath)-iPos)
getFileName = s
End Function
%>