[Quote=引用 8 楼 jobsen123 的回复:]
<%
'On Error Resume Next
Response.Buffer = true
Response.Clear
Dim ID,DownUrl
ID=Request.QueryString("ItemID")
ID=CSQL(HTML(ID),1)
If Not CKID(ID,"DownLoads","ID="&ID) Then
Response.Redirect("Errors.asp?u=Index.asp&e=")
End If
End If
If Conn.Execute("select SoftDownUrl from DownLoads where id="&ID&"").Eof And Conn.Execute("select SoftDownUrl from DownLoads where id="&ID&…
[/Quote]
<%
'On Error Resume Next
Response.Buffer = true
Response.Clear
Dim ID,DownUrl
ID=Request.QueryString("ItemID")
ID=CSQL(HTML(ID),1)
If Not CKID(ID,"DownLoads","ID="&ID) Then
Response.Redirect("Errors.asp?u=Index.asp&e=")
End If
End If
If Conn.Execute("select SoftDownUrl from DownLoads where id="&ID&"").Eof And Conn.Execute("select SoftDownUrl from DownLoads where id="&ID&"").Bof Then
Response.ContentType="text/html;charset=gb2312"
Response.Write("<script>alert(""无效的下载参数!"");</script>")
Response.End()
Else
DownUrl=Conn.Execute("select SoftDownUrl from DownLoads where id="&ID&"")(0)
End If
Dim SoftUrl
Dim Fso,Files,FileSize
Dim objStream,ContentType,FileName
If DownUrl<>"" Then
SoftUrl=server.MapPath(DownUrl)
'Response.Write SoftUrl
Set Fso=Server.CreateObject("Scripting.FileSystemObject")
Set Files=Fso.GetFile(SoftUrl)
FileSize=Files.size
FileName=Files.name
Set Files=Nothing
Set Fso=Nothing
'Response.Write FileName
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile SoftUrl
Select Case lcase(Right(FileName, 3))
Case ".rm"
ContentType = "audio/x-pn-realaudio"
End Select
Select Case lcase(Right(FileName, 4))
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-Excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".txt"
ContentType = "text/plain"
Case Else
ContentType = "application/octet-stream"
End Select
Response.Buffer=True
Response.Clear
Response.AddHeader "Content-Disposition", "attachment; filename=" & FileName
Response.AddHeader "Content-Length", FileSize
Response.Charset = "UTF-8"
Response.ContentType = ContentType
Response.BinaryWrite objStream.Read
Response.Flush
response.Clear()
objStream.Close
Set objStream = Nothing
End If
%>