来源:网络 | 2007-4-21 | (有2755人读过)
功能描述:上传图片文件到指定目录后,在本文件根据URL传入的文件名加上文件所在目录根据文件完整路径。再将该文件二进制数据流写入服务页面,从而达到隐藏图片真实地址防止外部引用图片的效果。
以下是引用片段:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Option Explicit
Const SysUrl="http://www.china6u6.com/uImg/"
Function ReadBinFile(fileName)
Dim objStream,bin
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile fileName
bin = objStream.Read
objStream.Close
ReadBinFile = bin
End Function
Function isSelfRefer()
Dim sHttp_Referer, sServer_Name
sServer_Name = CStr(Request.ServerVariables("HTTP_REFERER"))
if instr(sServer_Name,"80boby.com")<>0 or instr(sServer_Name,"freeat63.cn")<>0 then
IsSelfRefer = True
Else
IsSelfRefer = False
End If
End Function
if request.QueryString("Mark")="getPic" then
Dim RealUrl,fso
Dim uFileName:uFileName=Request.QueryString("x")
RealUrl=Server.MapPath("文件真实路径"&uFileName)
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if Not(fso.FileExists(RealUrl)) then RealUrl=Server.MapPath("logo.gif")
if Not(isSelfRefer) then
RealUrl=Server.MapPath("logo.gif")
end if
response.contenttype = "image/jpeg"
response.BinaryWrite ReadBinFile(RealUrl)
response.end
end if
%>
|