Method 1: Delete the image with a single FieldCode. It is relatively simple because the image field already exists in the bookpic field of the database table.
Copy code The Code is 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 file name
Set FSO = server. Createobject ("scripting. FileSystemObject ")
FSO. deletefile (server. mappath (upfile ))
Set FSO = nothing
Rs. Delete
Rs. Update
Rs. Close
Set rs = nothing
%>
Method 2: For multi-Image
ASP Program You can use ewebeditor when adding information. Article The image is extracted and put into a field. Copy code The Code is as follows: Id = request ("ID ")
If Id = "" then
Response. Write ("<SCRIPT> alert ('deletion 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 objects by path file name
Call dodelfile (asavepathfilename (n ))
Next
'Delete an 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