www.gusucode.com > 栽豆迷你博客 MiniBlog 3.0 正式版源码程序 > Upfile.asp

    <!--#include file="include/conn.asp" -->
<!--#include file="include/const.asp" -->
<!--#include FILE="include/cb_upload.asp"-->

<%
dim filebleid,upload,formPath,formName,file,fileExt,filename,userface

filebleid=Caluoob.UserID
set upload=new upload_5xSoft ''建立上传对象

 formPath=upload.form("filepath")
 ''在目录后加(/)
 if right(formPath,1)<>"/" then formPath=formPath&"/" 
for each formName in upload.file ''列出所有上传了的文件
 set file=upload.file(formName)  ''生成一个文件对象
 if file.filesize<100 then
 	response.write "<font size=2>请先选择你要上传的图片 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</font>"
	response.end
 end if

 if file.filesize>51200then
 	response.write "<font size=2>图片大小超过了限制 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</font>"
	response.end
 end if

 fileExt=lcase(right(file.filename,4))

 if fileEXT<>".gif" and fileEXT<>".jpg" then
 	response.write "<font size=2>文件格式不对 [ <a href=# onclick=history.go(-1)>重新上传</a> ]</font>"
	response.end
 end if 
 
 filename="face/"&filebleid&fileExt
 userface=filebleid&fileExt
 if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
  file.SaveAs Server.mappath(filename)   ''保存文件

 end if

Caluoob.Execute("update [cb_user] set userface='"&userface&"' where id="&filebleid)
 
set file=nothing
next
set upload=nothing
Response.redirect "settings.asp"
%>