<!-- #include file="conn.asp" -->
<!--#include file="upfile_class.asp"-->
<!-- #include file="bbsuser.asp" -->
<%
formPath="userheadimg"
if right(formPath,1)<>"/" then formPath=formPath&"/"

dim upload,file,upfile,formPath,ServerPath,FSPath,formName,companyName,oFile,upfilecount,SaveFileName,SavePathFileName
set upload=new Ftbbs_Class

upload.AllowExt="jpg|gif|bmp"
upload.GetData (51200)
if upload.isErr then
    select case upload.isErr
    case 1
        response.write "<script language='javascript'>"
        response.write "alert('上传文件类型有错！');"
        response.write "window.location.href='userimg.asp';"
        response.write "</script>"
        response.end 
    case 2
        response.write "<script language='javascript'>"
        response.write "alert('上传文件太大！');"
        response.write "window.location.href='userimg.asp';"
        response.write "</script>"
        response.end 
    end select
else
    for each formName in upload.file '列出所有上传了的文件
	   set oFile=upload.file(formname)
	   filesize=oFile.FileSize '取得文件大小
	   vfname=request.cookies("clubuser_id")
	   FileExt=oFile.FileExt '取文件扩展名 
	   fname = formPath&vfname & "." & FileExt
	   todbpath=vfname & "." & FileExt
       SavePathFileName = Server.MapPath(fname)
       upload.SaveToFile formName,SavePathFileName '保存文件
       if upload.iserr then 
         Response.Write upload.errmessage
       else
         sql="update clubuser set userimg='"&todbpath&"' where clubuser_name='"&request.cookies("name")&"'"
		 conn.Execute(sql)
		 response.redirect "userimg.asp"
       end if
       set oFile = nothing
    next
end if    
set upload=nothing
%>
