ASP刪除文章時,需要刪除eWebEditor上傳檔案

來源:互聯網
上載者:User
VB code
<%  '***********************************************'函數名:getPicUrl'作  用:獲得資訊裡的圖片地址'參  數:str  ----資訊'***********************************************function getPicUrl(str)    dim content,regstr,url    content=str&""    'regstr="src=.+?.(gif|jpg|bmp|doc)"    regstr="UploadFiles/.+?.(gif|jpg|bmp|doc)"    'url=Replace(Replace(Replace(RegExp_Execute(regstr,content),"'",""),"""",""),"src=","")     url=Replace(Replace(Replace(RegExp_Execute(regstr,content),"'",""),"""",""),"/UploadFiles/","")    getPicUrl=urlend functionFunction RegExp_Execute(patrn, strng)Dim regEx, Match, Matches,values '建立變數。Set regEx = New RegExp '建立Regex。regEx.Pattern = patrn '設定模式。regEx.IgnoreCase = true '設定是否區分字元大小寫。regEx.Global = True '設定全域可用性。Set Matches = regEx.Execute(strng) '執行搜尋。For Each Match in Matches '遍曆匹配集合。values=values&Match.Value&","NextRegExp_Execute = valuesEnd Function'***********************************************'函數名:DeleteFile'作  用:刪除檔案'參  數:file  ----檔案路徑'***********************************************Function DeleteFile(file)dim fsoSet fso = CreateObject("scripting.filesystemobject")'if fso.fileExists(file) then  fso.DeleteFile server.MapPath(file)  'Else   ' response.Write(" 檔案不存在!")'end ifSet fso = nothingEnd Function%><% iii=0typeid=request("typeid")pageon=request("pageon")type_name=request("typename")selectcount=request("selectcount")for ii=1 to selectcountid=request("cid"&ii)if id<>"" then'***********************************************'函數名:Delete'作  用:刪除檔案'參  數:file  ----檔案路徑'***********************************************set rsD=server.CreateObject("adodb.recordset")sqlD = "select * from content_table where id = "&id&""   rsD.open sqlD,con,1,3   if rsD.bof and rsD.eof then      Alert 1,"錯誤的參數!",""      response.End()   else      dim picUrl,picUrl1      dim picUrlArray      dim x,y      picUrl = getPicUrl(rsD("content"))            '刪除形象照片代碼開始       if rsD("prdPic")<>"" then     picUrl1 = replace(rsD("prdPic"),"../","/")             DeleteFile(picUrl1)    'response.Write("不為空白")          end if    '刪除形象照片代碼結束            if picUrl <> "" then         picUrl = left(picUrl,len(picUrl)-1)         picUrlArray = split(picUrl,",")         for x = 0 to ubound(picUrlArray)          if instr(picUrlArray(x),"/UploadFiles/") > 0 then                          DeleteFile(picUrlArray(x))            end if         next      end if            rsD.delete   end if   rsD.closestrSQL="delete from content_Table where id ="&id         CmdBegin adcmdtext,strSQL        CmdExec()iii=1%><%end ifnextif iii=1 then%><script>alert("已永久刪除!")location.href="info.asp?typeid=<%=typeid%>&pageon=<%=pageon%>&typename=<%=type_name%>"</script><%else%><script>alert("刪除失敗!")history.back()</script><%end if%>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.