主题:  删除文件不能实现?

yiliaocheng

职务:普通成员
等级:2
金币:2.0
发贴:631
注册:2005/12/29 19:33:15
#12006/4/13 20:44:53
本人做图片管理系统,把图片上传到文件夹PHOTO,数据库中photourl字段记录图片地址,用下列代码删除记录和PHOTO里的图片,可是图片没有删除啊,为什么啊?
代码:<!--#include file="adminconn.inc"-->
<%set fo=server.CreateObject("Scripting.FileSystemObject")
rs.open "select * from photo where id="&request.QueryString("id"),conn,3,3
FilePath=rs("photourl")&","&FilePath
if FileName<>"" then
fo.DeleteFile server.MapPath(FileName)
else
rs.delete
rs.update
rs.close
end if
set rs=nothing
set fo=nothing
response.write "<script language='javascript'>" & chr(13)
        response.write "alert('成功删除!');" & Chr(13)
        response.write "window.document.location.href='javascript:history.back(-1)';"&Chr(13)
        response.write "</script>" & Chr(13)
Response.End
%>



yiliaocheng

职务:普通成员
等级:2
金币:2.0
发贴:631
注册:2005/12/29 19:33:15
#22006/4/14 16:57:17
问题本人已经得到解决,不好意思麻烦各位。正确代码为:<!--#include file="adminconn.inc"-->
<%set fo=server.CreateObject("Scripting.FileSystemObject"
set rs=conn.execute("select photourl from photo where id="&request.QueryString("id")
    FilePath="../"&rs("photourl"&","&FilePath
conn.execute("delete from photo where id="&request.QueryString("id")
FilePath=split(FilePath,","
for each FileName in FilePath
    if FileName<>"" then
        fo.DeleteFile server.MapPath(FileName)
    end if
next
set fo=nothing
rs.close
set rs=nothing
response.write "<script language='javascript'>" & chr(13)
        response.write "alert('成功删除!');" & Chr(13)
        response.write "window.document.location.href='javascript:history.back()';"&Chr(13)
        response.write "</script>" & Chr(13)
Response.End
%>