代码如下:
<BR /><!--#include file="conn.asp"--> <BR /><% <BR />fileid=trim(request("fileid"))'要删除的记录ID <BR />set rs=server.createobject("adodb.recordset") <BR />sql="select * from shop_books where bookid=3090" <BR />rs.open sql,conn,3,2 <BR />upfile=rs("bookpic") '带路径和文件名 <BR />set fso=server.CreateObject("scripting.filesystemobject") <BR />fso.deletefile(server.MapPath(upfile)) <BR />set fso=nothing <BR />rs.delete <BR />rs.update <BR />rs.close <BR />set rs=nothing <BR />%> <BR /><BR /><STRONG>第二种方法:对于多图片的</STRONG><BR />asp程序下大家在添加信息的时候可以用ewebeditor,这个可以将文章种的图片提取后放到一个字段里面。<BR /><span><U></U></span> 代码如下:<BR />Id=Request("Id") <BR />If Id="" Then <BR />Response.Write("<script>alert('删除操作失败:请选择需要删除的信息!');hitory.go(-1);</script>") <BR />Else <BR />Id=Split(Id,",") <BR />For i=0 to UBound(Id) <BR />set oRs=SerVer.CreateObject("Adodb.recordset") <BR />sSql = "SELECT D_SavePathFileName FROM "&data&" WHERE ID="&id(i)&"" <BR />oRs.Open sSql, Conn, 0, 1 <BR />If Not oRs.Eof Then <BR />asSavePathFileName = oRs("D_SavePathFileName") <BR />Else <BR />asSavePathFileName="" <BR />End If <BR />oRs.Close <BR />Set oRs=Nothing <BR />Dim aSavePathFileName <BR />if len(aSavePathFileName)>0 then <BR />aSavePathFileName = Split(asSavePathFileName, "|") <BR />Dim n <BR />For n = 0 To UBound(aSavePathFileName) <BR />' 按路径文件名删除文件 <BR />Call DoDelFile(aSavePathFileName(n)) <BR />Next <BR />'删除文章 www.51frw.cn <BR />Conn.Execute("delete from Article where id="&id(i)&"") <BR />Next <BR />end if <BR />Sub DoDelFile(sPathFile) <BR />'On Error Resume Next <BR />Dim oFSO <BR />Set oFSO = Server.CreateObject("Scripting.FileSystemObject") <BR />if objFSO.fileExists(Server.MapPath(sPathFile)) then <BR />oFSO.DeleteFile(Server.MapPath(sPathFile)) <BR />end if <BR />Set oFSO = Nothing <BR />End Sub <BR />
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!