ASP实现隐藏下载地址和防盗

以下为引用的内容:
<% 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 "该文件不存在或者已经删除."
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 "该文件不存在或者已经删除."
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 "该文件数据不完整或许已损坏."
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
%>

调用
<%Call DownloadFIle("下载地址")%>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值