<% 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"))'就是你读取存在本地的文件,防止被 别人知道真实路径盗连的。 %>