注册 登录
编程论坛 ASP技术论坛

ASP删除一个图片和一个字段的值如何写

guaishi 发布于 2007-10-11 16:12, 789 次点击
我通过上传组件把图片上传到一图片文件夹中
现在想实现一个删除操作
要求图片物理删除
图片地址变空
请问如何操作可否提供参考源代码
4 回复
#2
xiapi2007-10-11 16:37

物理删除

set Fs=Server.CreateObject("Scripting.FileSystemObject")
pic="这里是路径"
If Fs.FileExists(server.mappath(pic)) Then
set Os = Fs.GetFile(server.mappath(pic))
Os.delete

#3
guaishi2007-10-11 16:56

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>图片删除</title>
</head>
<!--#include file="../include/Config.asp"-->
<!--#include file="check_login.asp"-->
<% img=request("img")
response.write img
set rs=server.CreateObject("adodb.recordset")
sql="select * from corpuser_info where img='"&img&"'"
rs.open sql,conn,3,3
db=rs("img")
response.write db
FilePath=Server.MapPath(db)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
IF fso.FileExists(FilePath) Then
fso.DeleteFile(FilePath)
End IF
Set fso = Nothing
rs.close
set rs=nothing

conn.close
set conn=nothing

response.write("图片删除成功")
%>


<body>
</body>
</html>
可以物理删除
但不能删除图片的地址在数据库的记录

#4
永夜的极光2007-10-11 16:59
rs.close前面加一句
rs("img")=""
rs.update
#5
guaishi2007-10-11 22:25

谢谢我已经成功实现了

1