ASP instance Tutorial: Hide download Address and burglar

Source: Internet
Author: User
Tags end servervariables

The following are the referenced contents:
<% 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 "The file does not exist or has been deleted."
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 "The file does not exist or has been deleted."
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 "The file data is incomplete or corrupted."
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

<%call DownloadFIle ("Download Address")%>



Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.