28,409
社区成员




<style>
body{font-size:9pt;
color:red;
}
td{font-size:9pt;
}
</style>
<%
Const ForReading=1
Const TristateTrue=-1 'Unicode
Const FILE_TRANSFER_SIZE=16384 '16k
'Use the following line for IIS4/PWS - this is the default for IIS5
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")
If objFileSystem.FileExists(Server.MapPath(Path)) Then
Set objFile = objFileSystem.GetFile(Server.MapPath(Path))
Else
Response.Write "<table width='25%' border='0' align='center' cellpadding='5' cellspacing='0'>"
Response.Write " <tr>"
Response.Write " <td><img src='Images/Error/01.jpg' width='447' height='183' /></td>"
Response.Write " </tr>"
Response.Write " <tr>"
Response.Write " <td align='center' valign='middle'>文件"&" "&Ucase(OldFileName)&" "&"不存在</td>"
Response.Write " </tr>"
Response.Write "</table>"
Response.End
end if
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 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 path, mimeType, sucess
FileName = Request.QueryString("FileName")
mimeType = "application/x-msdownload"
OldFileName = mid(FileName,instrrev(FileName,"/")+1)
if FileName = "" Then
Response.Write "无效文件名!"
Response.End
End if
FileExt = Mid(FileName, InStrRev(FileName,".") + 1) '取下载文件的后缀名
Select Case UCase(FileExt)
Case "ASP", "ASA", "ASPX", "ASAX", "MDB" ,"Jsp" ," Php"
Response.Write "<table width='25%' border='0' align='center' cellpadding='5' cellspacing='0'>"
Response.Write " <tr>"
Response.Write " <td><img src='Images/Error/01.jpg' width='447' height='183' /></td>"
Response.Write " </tr>"
Response.Write " <tr>"
Response.Write " <td align='center' valign='middle'>非法操作!禁止下载"&" "&Ucase(FileExt)&" "&"文件</td>"
Response.Write " </tr>"
Response.Write "</table>"
Response.End
End Select
sucess = TransferFile(FileName,mimeType,OldFileName)
%>