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
%>