ASP 在删除条目的同时删除里面的图片文件
<%dimID,Action,sqlDel,rsDel,FoundErr,ErrMsg,ObjInstalledID=trim(request("ID"))FoundEr...
<%
dim ID,Action,sqlDel,rsDel,FoundErr,ErrMsg,ObjInstalled
ID=trim(request("ID"))
FoundErr=False
ObjInstalled=IsObjInstalled("Scripting.FileSystemObject")
if ID="" or Action<>"Del" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>参数不足!</li>"
end if
if FoundErr=False then
if instr(ID,",")>0 then
dim idarr,i
idArr=split(ID)
for i = 0 to ubound(idArr)
call DelNews(clng(idarr(i)))
next
else
call DelNews(clng(ID))
end if
end if
if FoundErr=False then
response.write "<script language=""JavaScript"">history.go(-1);</script>"
else
call WriteErrMsg()
end if
sub DelNews(ID)
PurviewChecked=False
if DelUpFiles="Yes" then
sqlDel="select * from WQ_Photo where ID=" & CLng(ID)
Set rsDel= Server.CreateObject("ADODB.Recordset")
rsDel.open sqlDel,conn,1,3
filepath=server.mappath("../"&SaveUpFilesPath&rsDel("SmallPic"))
filepath2=server.mappath("../"&SaveUpFilesPath&rsDel("BigPic"))
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(filepath) then fso.DeleteFile(filepath),true
rs.movenext
if fso.FileExists(filepath2) then fso.DeleteFile(filepath2),true
else
Set fso = nothing
dim picUrl
dim picUrlArray
dim x,y
picUrl = getPicUrl(rsDel("content"))
if picUrl <> "" then
picUrl = left(picUrl,len(picUrl)-1)
picUrlArray = split(picUrl,",")
for x = 0 to ubound(picUrlArray)
if instr(picUrlArray(x),""&SaveUpFilesPath&"") > 0 then
DeleteFile(picUrlArray(x))
end if
next
end if
rsDel.delete
rsDel.update
set rsDel=nothing
end if
elseif DelUpFiles<>"Yes" then
sqlDel="select * from WQ_Photo where ID=" & CLng(ID)
Set rsDel= Server.CreateObject("ADODB.Recordset")
rsDel.open sqlDel,conn,1,3
rsDel.delete
rsDel.update
set rsDel=nothing
end if
end sub
%>
技术信息(用于支持人员)
错误类型:
Microsoft VBScript 编译器错误 (0x800A03F6)
缺少 'End'
/xindixj.com咸阳鑫迪橡胶制品有限公司/admin/photo_Del.asp, line 112
elseif DelUpFiles<>"Yes" then
浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; TencentTraveler 4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322) 展开
dim ID,Action,sqlDel,rsDel,FoundErr,ErrMsg,ObjInstalled
ID=trim(request("ID"))
FoundErr=False
ObjInstalled=IsObjInstalled("Scripting.FileSystemObject")
if ID="" or Action<>"Del" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>参数不足!</li>"
end if
if FoundErr=False then
if instr(ID,",")>0 then
dim idarr,i
idArr=split(ID)
for i = 0 to ubound(idArr)
call DelNews(clng(idarr(i)))
next
else
call DelNews(clng(ID))
end if
end if
if FoundErr=False then
response.write "<script language=""JavaScript"">history.go(-1);</script>"
else
call WriteErrMsg()
end if
sub DelNews(ID)
PurviewChecked=False
if DelUpFiles="Yes" then
sqlDel="select * from WQ_Photo where ID=" & CLng(ID)
Set rsDel= Server.CreateObject("ADODB.Recordset")
rsDel.open sqlDel,conn,1,3
filepath=server.mappath("../"&SaveUpFilesPath&rsDel("SmallPic"))
filepath2=server.mappath("../"&SaveUpFilesPath&rsDel("BigPic"))
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.FileExists(filepath) then fso.DeleteFile(filepath),true
rs.movenext
if fso.FileExists(filepath2) then fso.DeleteFile(filepath2),true
else
Set fso = nothing
dim picUrl
dim picUrlArray
dim x,y
picUrl = getPicUrl(rsDel("content"))
if picUrl <> "" then
picUrl = left(picUrl,len(picUrl)-1)
picUrlArray = split(picUrl,",")
for x = 0 to ubound(picUrlArray)
if instr(picUrlArray(x),""&SaveUpFilesPath&"") > 0 then
DeleteFile(picUrlArray(x))
end if
next
end if
rsDel.delete
rsDel.update
set rsDel=nothing
end if
elseif DelUpFiles<>"Yes" then
sqlDel="select * from WQ_Photo where ID=" & CLng(ID)
Set rsDel= Server.CreateObject("ADODB.Recordset")
rsDel.open sqlDel,conn,1,3
rsDel.delete
rsDel.update
set rsDel=nothing
end if
end sub
%>
技术信息(用于支持人员)
错误类型:
Microsoft VBScript 编译器错误 (0x800A03F6)
缺少 'End'
/xindixj.com咸阳鑫迪橡胶制品有限公司/admin/photo_Del.asp, line 112
elseif DelUpFiles<>"Yes" then
浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; TencentTraveler 4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询