老问题--删除图片问题(在线等待)

zql2008 2003-09-23 11:51:34
我们把图片上传上时,如果要把它删除掉是怎么样做呢?
不但是把数据库中的连接删除而且也要把文件夹中的图片也删除掉那是怎么样做到呢?(主要是要同时删除多张图片要怎么样做呢,我用的数据 库是access的)
...全文
42 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
富察咪咪 2003-09-24
  • 打赏
  • 举报
回复
楼上的是把文件夹中的文件全部删除
file=request("url") 这里接受多个参数

path="../uploadimage/"
set fso=server.createobject("Scripting.FileSystemObject")
strsql="select filename from photo where id=num1 or id=num2
rs.open strsql,conn,1,1
if not rs.eof and not rs.bof then
do while not rs.eof
file=rs("filename")
fso.deletefile Server.MapPath(path&file),true
loop
set fso=nothing
id=Request("num")
if id <>"" then
dim sql
sql="DELETE FROM photo WHERE num IN "
sql=sql &"(" & id & ")"
set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_conn_STRING
Command1.CommandText = sql
Command1.Execute()
zql2008 2003-09-24
  • 打赏
  • 举报
回复
file=request("url") 这里接受多个参数
这个我知道,但是里面的如where id=num1 or id=num2 是怎么回事呢(我怎么才能根据条件来半断呢),我从另一页传参只有一个num自动编号,url是图片名字,在上面我还是看有点晕呀
zql2008 2003-09-24
  • 打赏
  • 举报
回复
file=request("url") 这里接受多个参数
这个我知道,但是里面的如where id=num1 or id=num2 是怎么回事呢(我怎么才能根据条件来半断呢),我从另一页传参只有一个num自动编号,url是图片名字,在上面我还是看有点晕呀
coffee_cn 2003-09-23
  • 打赏
  • 举报
回复
sub delPic(picPath,picName)
if picPath<>"" then
picPath=server.MapPath(picPath)
else
exit sub
end if
SET fs=server.CreateObject("Scripting.FileSystemObject")
if FS.FileExists(picPath & "/" & picName) then
FS.DeleteFile picPath & "/" & picName,true
end if
set fs=nothing
end sub
富察咪咪 2003-09-23
  • 打赏
  • 举报
回复
用FSO删除,如果多条,从数据库中读出多条,循环删除
zql2008 2003-09-23
  • 打赏
  • 举报
回复
自己up
online 2003-09-23
  • 打赏
  • 举报
回复
Sub CleanUpGIF(GIFpath)
Dim objFS
Dim objFolder
Dim gif
set objFS = Server.CreateObject("Scripting.FileSystemObject")
set objFolder = objFS.GetFolder(GIFpath)
for each gif in objFolder.Files
if instr(gif.Name, ".gif") > 0 and DateDiff("n", gif.DateLastModified, now) > 10 then
objFS.DeleteFile GIFpath & "\" & gif.Name, True
end if
next
set objFolder = nothing
set objFS = nothing
End Sub
zql2008 2003-09-23
  • 打赏
  • 举报
回复
这是我的代码。谁能帮我修改一下呢?
<%@LANGUAGE="VBSCRIPT"%>

<!--#include file="../qq.asp" -->
<%
dim id
dim file
file=request("url")
path="../uploadimage/"
set fso=server.createobject("Scripting.FileSystemObject")
fso.deletefile Server.MapPath(path&file),true
set fso=nothing
id=Request("num")
if id <>"" then
dim sql
sql="DELETE FROM photo WHERE num IN "
sql=sql &"(" & id & ")"
set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = MM_conn_STRING
Command1.CommandText = sql
Command1.Execute()
%>
<script>
alert("删除成功!")
location.href="del_photo1.asp"
</script>
<% end if %>
<% response.write "<script> alert('对不起,您没选择');history.back(1);</script>"
%>
zql2008 2003-09-23
  • 打赏
  • 举报
回复
怎么没人来呢,我是一个菜鸟,有人帮帮忙吗?
zql2008 2003-09-23
  • 打赏
  • 举报
回复
怎么做到循环删除呢?请高手指点迷今。。。。。。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧