復制代碼 代碼如下:
% FunctIon DownloadFIle(StrFIle)
StrFIlename=StrFIle
Response.Buffer=True
Response.Clear
Set S=Server.CreateObJect("ADODB.Stream")
S.Open
S.Type=1
on Error Resume Next
Set Fso=Server.CreateObJect("ScrIptIng.FIleSystemObJect")
If Not Fso.FIleExists(StrFIleName) Then
From_Url=Cstr(Request.ServerVarIables("HTTP_REFERER"))
Serv_Url=Cstr(Request.ServerVarIables("SERVER_NAME"))
If MId(From_Url,8,len(Serv_Url)) > Serv_Url Then
Response.WrIte "該文件不存在或者已經(jīng)刪除."
Response.End
End If
Response.RedIrect Request.ServerVarIables("HTTP_REFERER")
Response.End
End If
FileExt=MId(StrFIlename,InStrRev(StrFIleName, ".")+1)
Select Case UCase(FIleExt)
Case "ASP", "ASA", "ASPX", "ASAX", "MDB", "PHP", "JSP", "SHTML", "HTML", "HTM", "TV", "DATA"
From_Url=Cstr(Request.ServerVarIables("HTTP_REFERER"))
Serv_Url=Cstr(Request.ServerVarIables("SERVER_NAME"))
If MId(From_Url,8,len(Serv_Url)) > Serv_Url Then
Response.WrIte "該文件不存在或者已經(jīng)刪除."
Response.End
End If
Response.RedIrect Request.ServerVarIables("HTTP_REFERER")
Response.End
End Select
Set F=Fso.GetFIle(StrFIlename)
IntFIlelength=F.SIze
s.LoadFromFIle(StrFIlename)
If Err Then
From_Url=Cstr(Request.ServerVarIables("HTTP_REFERER"))
Serv_Url=Cstr(Request.ServerVarIables("SERVER_NAME"))
If MId(From_Url,8,len(Serv_Url)) > Serv_Url Then
Response.WrIte "該文件數(shù)據(jù)不完整或許已損壞."
Response.End
End If
Response.RedIrect Request.ServerVarIables("HTTP_REFERER")
Response.End
End If
Set Upload=Server.CreateObJect("PersIts.Upload")
If Upload Is Nothing Then
Response.AddHeader "Content-DIsposItIon","attachment; FIlename="F.Name
Response.AddHeader "Content-Length",IntFilelength
Response.CharSet="UTF-8"
Response.ContentType="application/x-download"
Response.BinaryWrite S.Read
Response.Flush
S.Close
Set s=NothIng
Else
Upload.SendBinary StrFIlename,True,"application/x-download",False
End If
End FunctIon
%>
調(diào)用
復制代碼 代碼如下:
%Call DownloadFIle("下載地址")%>
您可能感興趣的文章:- IIS防盜鏈 ISAPI Rewrite圖片防盜鏈規(guī)則寫法
- ASP.NET 圖片加水印防盜鏈實現(xiàn)代碼
- Apache下MP3 防盜鏈的解決辦法
- php下通過偽造http頭破解防盜鏈的代碼
- php防盜鏈的常用方法小結(jié)
- asp.net下結(jié)合HttpHandler實現(xiàn)圖片防盜鏈
- 破解圖片防盜鏈的代碼(asp/php)測試通過
- asp 防盜鏈代碼(徹底屏蔽迅雷,旋風,快車下載站內(nèi)資源)
- Asp.net 圖片文件防盜鏈(尊重勞動成果)及BeginRequest事件學習