标题:ASP二进制流Stream方法显示图片并隐藏图片文件真实路径
只看楼主
VB爱上我
Rank: 6Rank: 6
等 级:贵宾
威 望:25
帖 子:478
专家分:52
注 册:2005-10-14
结帖率:100%
 问题点数:0 回复次数:0 
ASP二进制流Stream方法显示图片并隐藏图片文件真实路径
<img src="showpic.asp?Mark=getPic&x=a.jpg"/>

showpic.asp文件代码如下:
<%
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,")<>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("images/"&uFileName)
 Set fso = Server.CreateObject("Scripting.FileSystemObject")
 if Not(fso.FileExists(RealUrl)) then RealUrl=Server.MapPath("images/logo.gif")
 
 if Not(isSelfRefer) then
 RealUrl=Server.MapPath("images/logo.gif")
 end if
 
 response.contenttype = "image/jpeg"
 response.BinaryWrite ReadBinFile(RealUrl)
 response.end
end if
%>

文章出处:IT618资讯网(http://)
搜索更多相关主题的帖子: 二进制 图片 
2011-12-26 09:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-358634-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.041199 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved