删除文章同时删除图片

稿件来源: 互联网   撰稿作者: 太阳光   发表日期: 2008-09-17 10:08:18   阅读次数: 695   查看权限: 游客查看

asp删除文章时同时批量删除图片过程

 

'***********************************************
'函数名:getPicUrl
'作  用:获得信息里的图片地址
'参  数:str  ----信息
'***********************************************
function getPicUrl(str)
    dim content,regstr,url
    content=str&""
    regstr="src=.+?.(gif|jpg)"
    url=Replace(Replace(Replace(RegExp_Execute(regstr,content),"'",""),"""",""),"src=","")
    getPicUrl=url
end function

Function RegExp_Execute(patrn, strng)
Dim regEx, Match, Matches,values '建立变量。
Set regEx = New RegExp '建立正则表达式。
regEx.Pattern = patrn '设置模式。
regEx.IgnoreCase = true '设置是否区分字符大小写。
regEx.Global = True '设置全局可用性。
Set Matches = regEx.Execute(strng) '执行搜索。
For Each Match in Matches '遍历匹配集合。
values=values&Match.Value&","
Next
RegExp_Execute = values
End Function

'***********************************************
'函数名:DeleteFile
'作  用:删除文件
'参  数:file  ----文件路径
'***********************************************
Function DeleteFile(file)
dim fso
Set fso = CreateObject("scripting.filesystemobject")
'if fso.fileExists(file) then
  fso.DeleteFile server.MapPath(file)
'end if
Set fso = nothing
End Function

//=============================调用
sql = "select * from article where id = "&id&""
   rs.open sql,conn,1,3
   if rs.bof and rs.eof then
      Alert 1,"错误的参数!",""
      response.End()
   else
      dim picUrl
      dim picUrlArray
      dim x,y
      picUrl = getPicUrl(rs("content"))
      if picUrl <> "" then
         picUrl = left(picUrl,len(picUrl)-1)
         picUrlArray = split(picUrl,",")
         for x = 0 to ubound(picUrlArray)
            if instr(picUrlArray(x),"/upfiles/") > 0 then
              DeleteFile(picUrlArray(x))
            end if
         next
      end if
      
      rs.delete
   end if
   rs.close

关键词: 删除图片,asp   编辑时间: 2010-09-17

  • 感到高兴

    1

    高兴
  • 感到支持

    0

    支持
  • 感到搞笑

    0

    搞笑
  • 感到不解

    0

    不解
  • 感到谎言

    0

    谎言
  • 感到枪稿

    0

    枪稿
  • 感到震惊

    0

    震惊
  • 感到无奈

    0

    无奈
  • 感到无聊

    0

    无聊
  • 感到反对

    0

    反对
  • 感到愤怒

    0

    愤怒
100%(2)
0%(0)
上一篇:js幻灯片播放器
下一篇:js字符串操作
共有0 条评论 发言请遵守【相关规定

网友评论

会员头像
发 表同步腾讯微博    验证码:  点击更新请先登陆
  • 暂无评论
关闭模块文章图片 article Pictrue
  • 我的妈妈爸爸
  • 基于koa2+mysql+vue2.0+Element阳光内容管理系统
  • 代码覆盖率工具 Istanbul 入门教程
  • 全栈工程师的武器——MEAN
  • 9款超炫的 CSS3 复选框(Checkbox)
  • 微信开发在线翻译功能
  • CSS3那些不为人知的高级属性
  • 给easyui的datebox添加清空事件
  • flash写字效果
  • kendoUI系列教程之DropDownList下拉菜单
  • kendoUI系列教程之datetimepicker日期时间选择
  • kendoUI系列教程之datepicker日期选择
  • kendoUI系列教程之combobox下拉列表框
  • kendoUI系列教程之colorpicker
  • kendoUI系列教程之calendar日历表
  • kendoUI系列教程之autocomplete自动补齐