<% From_url = Cstr(Request.ServerVariables("HTTP_REFERER")) Serv_url = Cstr(Request.ServerVariables("SERVER_NAME")) if mid(From_url,8,len(Serv_url)) <> Serv_url and mid(From_url,8,len(Serv_url))<>"ITstudy.cn" and mid(From_url,8,len(Serv_url))<>"www.ITstudy.cn" then response.write "您下載的軟件來自IT學習網,請直接從主頁下載,謝謝<br>" '防止盜鏈 response.write "<a href=http://www.ITstudy.cn>IT學習網http://www.ITstudy.cn</a>" '防止盜鏈 response.end end if %>
第二種:
復制代碼 代碼如下:
<% '定義函數,用ADODB.Stream讀取二進制數據 Function ReadBinaryFile(FileName) Const adTypeBinary = 1 Dim BinaryStream Set BinaryStream = CreateObject("ADODB.Stream") BinaryStream.Type = adTypeBinary BinaryStream.Open BinaryStream.LoadFromFile FileName ReadBinaryFile = BinaryStream.Read End Function Response.AddHeader "Content-Disposition", "attachment;filename=2.gif"'文件名 Response.ContentType = "image/GIF" '設置(1) response.Binarywrite ReadBinaryFile(server.mappath("2.gif"))'就是你讀取存在本地的文件,防止被 別人知道真實路徑盜連的。 %>