First method: This is the code that deletes the picture of the word segment. Simple, because the picture field already exists in the Bookpic field of the database table.
Copy Code code as follows:
<!--#include file= "conn.asp"-->
<%
Fileid=trim (Request ("Fileid")) ' ID of the record to be deleted
Set Rs=server.createobject ("Adodb.recordset")
Sql= "SELECT * from Shop_books where bookid=3090"
Rs.Open sql,conn,3,2
Upfile=rs ("Bookpic") ' with path and filename
Set Fso=server. CreateObject ("Scripting.FileSystemObject")
Fso.deletefile (server. MapPath (Upfile))
Set fso=nothing
Rs.delete
Rs.update
Rs.close
Set rs=nothing
%>
the second method: for multiple images
Under the ASP program, you can use ewebeditor when adding information, this can be extracted from the article and put into a field.
Copy Code code as follows:
Id=request ("Id")
If id= "" Then
Response.Write (' <script>alert (' delete operation failed: Please select the information you want to delete! '); Hitory.go ( -1);</script> ")
Else
Id=split (Id, ",")
For i=0 to UBound (Id)
Set Ors=server.createobject ("Adodb.recordset")
sSQL = "Select D_savepathfilename from" &data& "WHERE id=" &id (i) & ""
oRS.Open sSQL, Conn, 0, 1
If not ors.eof Then
Assavepathfilename = ORs ("D_savepathfilename")
Else
Assavepathfilename= ""
End If
Ors.close
Set ors=nothing
Dim Asavepathfilename
If Len (asavepathfilename) >0 Then
Asavepathfilename = Split (assavepathfilename, "|")
Dim N
For n = 0 to UBound (asavepathfilename)
' Delete file by path filename
Call Dodelfile (Asavepathfilename (n))
Next
' Delete Article www.jb51.net
Conn.execute ("Delete from Article where id=" &id (i) & "")
Next
End If
Sub Dodelfile (Spathfile)
' On Error Resume Next
Dim oFSO
Set oFSO = Server.CreateObject ("Scripting.FileSystemObject")
If Objfso.fileexists (Server.MapPath (spathfile)) Then
Ofso.deletefile (Server.MapPath (spathfile))
End If
Set oFSO = Nothing
End Sub