asp过滤图片
1. asp截取+过滤输出问题
<%
'======================================
'过滤HTML
'=====================================
function nohtml(byval str)
if isnull(str) or trim(str)="" then
nohtml=""
exit function
end if
dim re
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.Pattern="(\<.[^\<]*\>)"
str=re.replace(str," ")
re.Pattern="(\<\/[^\<]*\>)"
str=re.replace(str," ")
set re=nothing
str=replace(str,chr(34),"")
str=replace(str,"'","")
str=replace(str,"","")
nohtml=trim(str)
end function
'**************************************************
'函数名:gotTopic
'作 用:截字符串,汉字一个算两个字符,英文算一个字符
'参 数:str ----原字符串
' strlen ----截取长度
'返回值:截取后的字符串
'**************************************************
function gotTopic(str,strlen)
if str="" then
gotTopic=""
exit function
end if
dim l,t,c, i
str=replace(replace(replace(replace(str,""," "),""",chr(34)),">",">"),"<","<")
l=len(str)
t=0
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
gotTopic=left(str,i) & "…"
exit for
else
gotTopic=str
end if
next
gotTopic=replace(replace(replace(replace(gotTopic," ",""),chr(34),"""),">",">"),"<","<")
end function
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<%
dim content
content="<P><FONT face=Verdana>中国国际中小企业博览会经国务院批准,由中国国家发展和改革委员会、财政部、商务部、工商行政管理总局、银行业监督管理委员会、广东省人民政府共同主办。于每年9月中下旬在广州(琶州)国际会议展览中心举行。从2004起迄今已成功举办了4届,其中2007年展会面积11万名方米,参观观众逾20万人次。作为我国政府为促进中小企业发展而举办的最高级别展会之一,中博会每年都和一个友好国家共同主办,组织该国家特色产业中小企业参展,2008年第五届中博会将由韩国作为合作国家共同举办。</FONT></P><P><FONT face=Verdana><FONT face=Verdana作为中博会的主办方和主要承办方,广东省政府高度重视中博会的组织工作。为了继续办好中博会,促进我省现代服务业的发展和制造业的产业升级,本届中博会将设立中小企业服务馆。参展商主要由生产性服务业企业组成,生产性服务业是与制造业直接相关的配套服务业,它通过制造业提供智力型服务来提高其生产效率、降低其交易成本,进而推动制造业的发展,在现代经济发展中具有不可替代的作用。</FONT></FONT></P><FONT face=Verdana><FONT face=Verdana><P><BR>届中博会中小企业服务馆将设信息化及电子商务展区、教育及人力资源展区、现代物流及贸易服务展区、专业技能级综合服务区4个展区。致力于针对中小企业的全方位需要,为国内中小企业提供一站式的实用服务、市场信息及商贸咨询等服务,协助中小企业拓展市场以及寻找合适业务伙伴。服务馆作为本届中博会的新亮点,是各种生产性服务业企业宣传品牌、推介服务、结识新客户密切老客户、拓展生意渠道的极佳场所。</P><P></FONT></FONT></P>"
%>
<%=gotTopic(nohtml(content),25)%>
</body>
</html>
2. asp截取字符 怎样过滤掉图片,让图片不显示
加个判断条件吧,过滤<img开头,如果有<img开头,则到第一/>结束。过滤掉。
3. 请大家推荐asp截取字符 怎样过滤掉图片 只显示文本
我对这个不太懂,我给你提示下
ASP在截取时默认是截取所有字符编码
你可以过滤掉非
ASC
II编码的字符
就可以了
4. asp截取字符 怎样过滤掉图片 只显示文本
不知道你说的图片时怎麼显示的,如果是html代码的话,就过滤掉以<img开头的字符
5. asp过滤图片
^使用asp的正则表达式
用这个函数过滤专
function noHTML(str)
dim re
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
're.Pattern="(\<.[^属\<]*\>)"
'str=re.replace(str," ")
re.Pattern="(\<img[^\<]*\>)"
str=re.replace(str," ")
nohtml=str
set re=nothing
end function
6. asp中如何过滤掉特殊字符
|user=replace(trim(request.form("uName")),"'","''")
password=replace(trim(request.form("Password")),"'","''")
if instr(user,"%") or instr(user,"#") or instr(user,"?") or instr(user,"|") or instr(user,"'") then
response.write "<script language=javascript>alert('您的姓名含有非法字符!');this.location.href='login.asp';</script>"
response.end
end if
if instr(password,"%") or instr(password,"#") or instr(password,"?") or instr(password,"|") then
response.write "<script language=javascript>alert('您的密码含有非法字符!');this.location.href='login.asp';</script>"
response.end
end if 我自己做的,希望对你有帮助
7. ASP如何过滤图片代码
先截取代码
a="<img src='asd.jpg'>"
if instr(a,"img src=")<>0 then
a=""
end if
8. ASP过滤HTML中的图片问题
首先来分析一下带图片链接的标签
<a href="CC"><img src="XXX /></a>
这是标准的
下面是思路具体代码你自己专写去吧
假设htmlstr是你带有要属去掉的图片html代码
首先用instr()函数找到"<a"出现的位置
然后从这个位置开始找到第一个"</a>"出现位置
然后建立一个临时的字符串变量tempstr
把刚才的那段用mid()函数赋值给tempstr
再在tempstr中用instr()函数查找是否包含img标签
如果包含就是图片链接
用replace函数吧htmlstr中的tempstr替换成""空白
大概就是这思路
你看着写吧
应该用正则表达式也可以实现可惜呀本人功力不够正则表达式还没研究透彻
有货的朋友拿出来亮亮
9. ASP字符过滤。
username=trim(request.form("username"))
'定义一个数组
badCode="<,%,@,upload"
'分割数据
badCode=split(badCode,",")
'从第一个循环到最后一回个
for i = 0 to ubound(badCode)
username=replace(username,badCode(i),"") '把这些字符替换为答空
next
10. 关于ASP上传图片二进制处理,谁能帮我解释一下asp的二进制的过滤工作原理,要详细的
uppic.asp上传程序名
<%
dim rs
dim formsize,formdata,bncrlf,divider,datastart,dataend,mydata
formsize=request.totalbytes '取得客户端发过来的大小
formdata=request.binaryread(formsize)'把客户发过来的数据转成二进制作
bncrlf=chrB(13) & chrB(10)
divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1)
datastart=instrb(formdata,bncrlf & bncrlf)+4
dataend=instrb(datastart+1,formdata,divider)-datastart
mydata=midb(formdata,datastart,dataend)'上面总共是取得图片的二进制数据
%>
<!--#include file="conn.asp"-->
<%
sql="select * from pic order by id desc"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn,3,2
rs.addnew
rs("big").appendchunk mydata '增加到数据库中
rs.update
set rs=nothing
set conn=nothing
%>
接下来是显示图片
display.asp
<!--#include file="conn.asp"--> <%
id=request("id")
set rs=server.createobject("ADODB.recordset")
sql="select * from pic where id=" & id
rs.open sql,conn,1,1
Response.ContentType = "text/html" '显示图片的格式也可以用
'Response.ContentType = "image/gif" 以gif显示
'Response.ContentType = "image/jpg" 以jpg显示
Response.BinaryWrite rs("big") '显示图片
rs.close
set rs=nothing
set connGraph=nothing
%>