功能描述:上傳圖片文件到指定目錄後,在本文件根據URL傳入的文件名加上文件所在目錄根據文件完整路徑。再將該文件二進制數據流寫入服務頁面,從而達到隱藏圖片真實地址防止外部引用圖片的效果。
以下是引用片段:
<%@LANGUAGE="VBSCRipT" CODEPAGE="936"%>
<%
Option Explicit
Const SysUrl="http://www.80Boby.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
%>