<!--#include file="z_t_upload.asp"-->
<!--#include file="common.asp"-->
<%
'on error resume next
dim upload,file,formName,formPath,filename,fileExt
set upload=new upload_5xSoft ''建立上传对象

'定义上传目录
formPath="logofile/"
'定义上传文件大小限制
MaxFileSize=500
'定义上传文件类型限制
UpFileType="gif|png|psd|jpg|bmp"

''在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/"

for each formName in upload.file ''列出所有上传了的文件
 set file=upload.file(formName)  ''生成一个文件对象
 if file.filesize<1 then
	response.write "<script>alert('请先选择你要上传的文件');</script>"
	response.end
 end if
 	
 if file.filesize>(MaxFileSize*1024) then
	response.write "<script>alert('文件大小超过了限制"&CStr(MaxFileSize)&"K');</script>"
	response.end
 end if

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

 arrUpFileType=split(UpFileType,"|")
 for i=0 to ubound(arrUpFileType)
	if fileEXT=trim(arrUpFileType(i)) then
		EnableUpload=true
		exit for
	end if
 next
 
 if fileEXT="asp" or fileEXT="asa" or fileEXT="aspx" or fileEXT="php" or fileEXT="jsp" or fileEXT="dll" or fileEXT="exe"  or fileEXT="vbs" then
	EnableUpload=false
 end if
 
 if EnableUpload=false then
	response.write "<script>alert('只允许上传"&CStr(UpFileType)&"K');</script>"
	response.end
 end if
 
 randomize
 ranNum=int(90000*rnd)+10000
 filename=upload.form("HiddMethod")&"."&year(now)&month(now)&day(now)&"."&ranNum&"."&fileExt
 
 if file.FileSize>0 then         '如果 FileSize > 0 说明有文件数据
  file.SaveAs Server.mappath(formPath&FileName)   ''保存文件
 end if
 response.write Server.mappath(formPath&FileName)
 set file=nothing
 
 'change Thumbnail info of database
response.write "<script>parent.setfilesrc('"&FileName&"')</script>"
response.write "<script>parent.close();</script>"
next
set upload=nothing  ''删除此对象

%>