请问大家一个关于删除记录的问题
请问大家怎样在删除记录的同时删除上传的图片?
<%
Action = Trim(Request.QueryString("Action"))
'------------------------------------------------------------------------
'上传新文件,删除文件夹垃圾文件
'------------------------------------------------------------------------
sub DeleteFile(path) '定义DeleteFile函数
dim fs,file
path = Server.mapPath(path)
set fs = CreateObject("Scripting.FileSystemObject")
if not fs.FileExists(path) then
else
fs.DeleteFile(path) '删除所要删除的文件
end if
end sub
If Action = "Copyring_Song" Then '删除上传的MP3文件
Id = Trim(Request.QueryString("Id"))
if Id <> "" then
'------------------查询要删除歌曲的路径地址-----------------------------
set rs_so=server.createobject("adodb.recordset")
sql_so="select * from Copyright_Song where Id="&Id
rs_so.open sql_so,conn,1,3
'执行删除函数,删除查询出内容文件
Call DeleteFile("../Manage_Copyring/"&rs_so("Song_Down_Url")&"")
'删除数据库中的文件路径
Conn.Execute = "UpDate Copyright_Song Set Song_Down_Url = Null Where Id = "&Id
'执行删除完成跳转到曲目信息修改页面
Response.Redirect "../Manage_Copyring/Copyright_update_list.asp?action=Copyring_Song&Song_Id="&Id&""
rs_so.close
Set rs_So=Nothing
Else
Response.Write "<script language = javascript>alert('所需的参数错误!');history.back(-1)</script>"
Response.End
End If
End If
If Action = "Song_Cut" Then '删除上传的剪辑
CutId = Trim(Request.QueryString("CutId"))
Sql_Cut_D = "Select Down_Url From Copyright_Down Where Id = "&CutId
Set Rs_Cut_D = Server.CreateObject("Adodb.Recordset")
Rs_Cut_D.Open Sql_Cut_D,Conn,1,3
'执行删除函数,删除上传的原文件
Call DeleteFile("../Manage_Copyring/"&Rs_Cut_D("Down_Url")&"")
'删除数据库中的文件路径
Conn.Execute = "UpDate Copyright_Down Set Down_Url = Null Where Id = "&CutId
'执行删除完成跳转到剪辑信息修改页面
Response.Redirect "../Manage_Copyring/Copyright_update_list.asp?action=Song_Cut&CutId="&CutId&""
Rs_Cut_D.Close
Set Rs_Cut_D = Nothing
End If
If Action = "Copyring_Agreement" Then '删除上传的协议
Id = Trim(Request.QueryString("Id"))
If Id <> "" Then
Set rs_Agr = server.CreateObject("adodb.recordset")
sql_Agr = "select * from Copyright_Agreement where Id="&Id
rs_Agr.open sql_Agr,conn,1,3
'执行删除函数,删除查询出版权人协议内容文件
call DeleteFile(""&rs_Agr("DownUrl_Agreement")&"")
'删除数据库中的文件路径
Conn.Execute = "UpDate Copyright_Agreement Set DownUrl_Agreement = Null Where Id = "&Id
'执行删除完成跳转到版权人协议信息修改页面
Response.Redirect "../Manage_Copyring/Copyright_update_list.asp?action=Copyright_Agreement&Id="&Id&"&Number_Agreement="&rs_Agr("Number_Agreement")&"&CopyrightId="&rs_Agr("CopyrightId")&""
rs_Agr.close
Set RS_Agr=Nothing
Else
Response.Write "<script language = javascript>alert('所需的参数错误!');history.back(-1)</script>"
Response.End
End IF
End If
conn.close
Set conn=Nothing
%>
这是我写的,修改文件的时候删除数据库里上传的文件或图片.
你改一下,删除的时候加上就可以了