删除记录并删除上传图片
这段代码可在同一页面执行删除新闻,并删除新闻上传的图片等,但只能对单一记录进行删除! 给新手看看吧!!
vb 代码
- <%if request.QueryString("action")="del" then
-
dim fso,file,i
- Set rs = Server.CreateObject("adodb.recordset")
-
sql=
"select * from news where news_id in ("&request("selectdel")")" -
rs.open sql,conn,1,3
-
file=rs(
"pic_url") -
set fso=server.CreateObject(
"Scripting.FileSystemObject") -
if fso.FileExists(server.mappath(
"../"&file)) then - fso.deletefile(server.mappath("../"&file))
- end if
- set fso=nothing
- conn.execute "delete from news where news_id in ("&request("selectdel")")"
- response.Redirect "news_list.asp"
- end if
- %>