<!--#include file="conn.asp"-->
<%
dim delid
delid = 1 '要删除的ID号
'取得ID号对应的文件名
set rs = conn.Execute("select picname from pic where id="&delid)
mypic = Split(rs("picname"),",")
'删除记录.
conn.Execute("Delete From pic where id="&delid)
For i=0 to UBound(mypic)
filepath = Server.MapPath("pic/"&mypic(i))
Response.Write filepath
set FSO = Server.CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(filepath) Then
FSO.deletefile(filepath)
End If
Next
%>
<%
url1=request("url1")
id=request("id")
DL=request("DL")
del_id=Request("delid")
del_bz=Request("delbz")
JieDuanName=Request("JieDuanName")
del_id=Cint(del_id)
strSql="select * from HX_Fileinfo where FID="&del_id
rs1.open strSql,Conn,1,3
if not rs1.eof then
whichfile=server.mappath(rs1("LuJing"))
Set fs = CreateObject("Scripting.FileSystemObject")
Set thisfile = fs.GetFile(whichfile)
thisfile.Delete True
end if
id=trim(rs1("HeTongID"))
rs1.delete
rs1.close
set rs1=nothing
if DL=1 then
Response.Redirect "H_file_Show_db.asp?JieDuanName="&JieDuanName&"&url1="&url1&"&ID="&id
end if
Response.Redirect url1
%>
用相对路径:
set fso=server.createobject("scripting.filesystemobject")
if fso.fileExists("pic/" & rs("图片的名字")) then
fso.DeleteFile "pic/" & rs("图片的名字"),true
end if
set fso=nothing
<!--#include file="conn.asp"-->
<%
dim delid
delid = 2 '要删除的ID号
'取得ID号对应的文件名
set rs = conn.Execute("select picname from pic where id="&delid)
'转成真实地址
filepath = Server.MapPath("pic/"&rs("picname"))
conn.Execute("Delete From pic where id="&delid)
'执行删除文件操作
set FSO = Server.CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(filepath) Then
FSO.deletefile(filepath)
End If
%>