'****************** '对上传头象进行过滤与改名 if Cint(Forum_Setting(7))=1 then on error resume next dim objFSO,upfilename,newfilename dim upface,memberid set rs=conn.execute("select userid,face from [user] where userid="&userid) memberid=rs(0) upface=trim(rs(1)) newfilename="" upfilename=split(upface,"/") if ubound(upfilename)=1 and upfilename(0)="uploadFace" then if instr(upfilename(1),"_")=0 then newfilename="uploadFace/"&memberid&"_"&upfilename(1) /用户定义的头像变为uploadFace/用户ID Set objFSO = Server.CreateObject("Scripting.FileSystemObject") if objFSO.fileExists(Server.MapPath(upface)) then objFSO.movefile ""&Server.MapPath(upface)&"",""&Server.MapPath(newfilename)&"" end if If Err.Number = 0 Then conn.execute("update [user] set face='"&newfilename&"' where userid="&userid) end if set objFSO=nothing end if end if rs.close set rs=nothing end if '对上传头象进行过滤与改名结束 '****************
if objFSO.fileExists(Server.MapPath(upface)) then objFSO.movefile ""&Server.MapPath(upface)&"",""&Server.MapPath(newfilename)&"" /看见没有?最关键的部分来了,如果检测到upface代表的文件存在,则对改文件进行移动并改名!