<!-- #include file="conn.asp" --> <% id=request("id") set rs=conn.execute("select * from news_Info where id="&id&" order by ID DESC") AA=rs("n_content") Set RE=NEW REGEXP RE.GLOBAL=TRUE RE.Pattern = "(src=)(' ¦"&CHR(34)&" ¦ )?(.[^' ¦ ¦"&CHR(34)&"]*)(\.)(jpg ¦gif ¦png ¦bmp ¦jpeg)(' ¦"&CHR(34)&" ¦ ¦>)?" ' Set Matches = RE.Execute(AA) ' 执行搜索。 For Each Match in Matches allpicurl=allpicurl&Replace(SERVER.HTMLENCODE(MATCH),"src=","")&" ¦" Next '搜索完成 checkchoice=split(allpicurl," ¦") '开始截取 Set fs = Server.CreateObject("Scripting.FileSystemObject") for i=0 to UBound(checkchoice) mulu=checkchoice(i) if fs.FileExists(mulu) then '判断是否有存在图片 fs.DeleteFile mulu, True'删除图片 else response.write "无图片"&checkchoice(i) end if next conn.execute("delete from news_info where id='"&id&"'") %>
基本上搜索功能没有问题!主要在删除方面有问题!! —————————————————————————————————————————— Set fs = Server.CreateObject("Scripting.FileSystemObject") for i=0 to UBound(checkchoice) mulu=checkchoice(i) if fs.FileExists(mulu) then '判断是否有存在图片 fs.DeleteFile mulu, True'删除图片 else response.write "无图片"&checkchoice(i) end if next conn.execute("delete from news_info where id='"&id&"'") —————————————————————————————————————————————— 应该是上面这个地方有问题,不过老是搞不好! 当我将checkchoice(i) 输出的时候,图片的地址是正常的!但是老是无法删除! 后来我测试删除,就直接将mulu="../uploadfiles/20080430/20080430004709676.jpg" 却可以删除!不知道怎么回事
checkchoice=split(allpicurl," ¦") Set fs = Server.CreateObject("Scripting.FileSystemObject") for i=0 to UBound(checkchoice) mulu=Server.MapPath(checkchoice(i)) if fs.FileExists(mulu) then fs.DeleteFile mulu, True else response.write checkchoice(i) end if next ______________________________________________________________ 上面是改了的
mulu="/uploadfiles/20080430/20080430004709676.jpg" Set fs = Server.CreateObject("Scripting.FileSystemObject") if fs.FileExists(mulu) then fs.DeleteFile mulu, True else response.write checkchoice(i) end if ———————————————————————————————————————— 这个可以!!如上: 但是到了截取的时候!如下: checkchoice=split(allpicurl," ¦") Set fs = Server.CreateObject("Scripting.FileSystemObject") for i=0 to UBound(checkchoice) mulu=Server.MapPath(checkchoice(i)) if fs.FileExists(mulu) then fs.DeleteFile mulu, True else response.write checkchoice(i) end if —————————————————————————————————————————— 干脆不删除,就判断看看输出的路径对不对!结果输出来的都是对的 如下: checkchoice=split(allpicurl," ¦") Set fs = Server.CreateObject("Scripting.FileSystemObject") for i=0 to UBound(checkchoice) response.write checkchoice(i) next —————————————————————————————————————————