Function description: After uploading the image file to the specified directory, the file name passed in the URL is added to the directory where the file is located based on the full path of the file. Then the binary data stream of the file is written to the service page, thereby achieving the effect of hiding the real address of the image and preventing external reference to the image.
Here is a quote:
< %@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("Real path of file"&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
%>