求教asp,删除记录里的图片文件问题?
<ahref="photodel.asp?Action=Del"onClick="returnConfirmDel();">更改头像</a>photodel.asp:<!...
<a href="photodel.asp?Action=Del"onClick="return ConfirmDel();">更改头像</a>
photodel.asp:
<!--#includefile="conn.asp"-->
<%
if session("usename")="" then
Response.Write "<scriptLanguage=Javascript>alert('您还没登陆,请先登陆!');location.href ='新主页2.asp';</script>"
response.End()
end if
pic=request.Form("pic")
set rs=server.createobject("adodb.recordset")
sql="select * from user where username='"&session("username")&"'"
rs.open sql,conn,3,2
upfile=ras("touxiang")
setfso=server.CreateObject("scripting.filesystemobject")
fso.deletefile(server.MapPath(upfile))
set fso=nothing
rs.delete
rs.update
rs.close
set rs=nothing
response.Redirect "头像添加.asp"
%>
问题:
一, photodel.asp会删除user的整条记录加保存的头像图片,而不是仅仅删除字段“touxiang“里保存的头像图片。
二, 字段“touxiang“为空时,会出现类型不匹配“server.MapPath” 展开
photodel.asp:
<!--#includefile="conn.asp"-->
<%
if session("usename")="" then
Response.Write "<scriptLanguage=Javascript>alert('您还没登陆,请先登陆!');location.href ='新主页2.asp';</script>"
response.End()
end if
pic=request.Form("pic")
set rs=server.createobject("adodb.recordset")
sql="select * from user where username='"&session("username")&"'"
rs.open sql,conn,3,2
upfile=ras("touxiang")
setfso=server.CreateObject("scripting.filesystemobject")
fso.deletefile(server.MapPath(upfile))
set fso=nothing
rs.delete
rs.update
rs.close
set rs=nothing
response.Redirect "头像添加.asp"
%>
问题:
一, photodel.asp会删除user的整条记录加保存的头像图片,而不是仅仅删除字段“touxiang“里保存的头像图片。
二, 字段“touxiang“为空时,会出现类型不匹配“server.MapPath” 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询