<!--#include file="chklogin.asp"-->
<!--#include file="upload.asp"-->
<%
set upload=new upload_file
if upload.form("act")="uploadfile" then
	filepath=trim(upload.form("filepath"))
	filelx=trim(upload.form("filelx"))
	
i=0
for each formName in upload.File
set file=upload.File(formName)
 
 fileExt=lcase(file.FileExt)	'得到的文件扩展名不含有.
 if file.filesize<100 then
 	errma("请先选择你要上传的文件！")
	response.end
 end if
 if (filelx<>"swf") and (filelx<>"jpg") then 
 	errma("该文件类型不能上传！")
	response.end
 end if
 if filelx="swf" then
	if fileext<>"swf"  then
		errma("只能上传swf格式的Flash文件！")
		response.end
	end if
 end if
 if filelx="jpg" then
	if fileext<>"gif" and fileext<>"jpg"  then
		errma("只能上传jpg或gif格式的图片！")
		response.end
     	end if
 end if
 if filelx="swf" then
	if file.filesize>(3000*1024) then
		errma("最大只能上传 3M 的Flash文件！")
		response.end
	end if
 end if
 if filelx="jpg" then
	if file.filesize>(1000*1024) then
		errma("最大只能上传 1000K 的图片文件！")
		response.end
	end if
 end if

 'randomize
 'ranNum=int(90000*rnd)+10000
 'filename=filepath&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExt
 filename=filepath&session("userid")&"."&fileExt
%>
<%
 if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
  'file.SaveAs Server.mappath(filename)   ''保存文件
  file.SaveToFile Server.mappath(FileName)
  'response.write file.FileName&"　　上传成功!　　<br>"
  'response.write "新文件名："&FileName&"<br>"
  'response.write "新文件名已复制到所需的位置，可关闭窗口！"
  if filelx="swf" then
  response.write "<script>window.opener.document."&upload.form("FormName")&".size.value='"&int(file.FileSize/1024)&" K'</script>"
  end if
  response.write "<script>window.opener.document."&upload.form("FormName")&"."&upload.form("EditName")&".value='"&FileName&"'</script>"
  response.write "<script>window.opener.document.images.userpic.src='"&FileName&"'</script>"
%>
<%
 end if
 set file=nothing
	next
	set upload=nothing
end if
%>
<script language="javascript">
window.alert("文件上传成功!");
window.close();
</script>
<%function errma(errstr)%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>上传失败</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>
<br>
<table width="360" border="0" align="center" cellpadding="0" cellspacing="1" class="left_bg">
  <tr>
    <td height="26" align="center" bgcolor="#62A11C"><font color="#FFFFFF"><b>上传没有成功!</b></font></td>
  </tr>
  <tr>
    <td height="104" align="center" bgcolor="#FFFFFF"><font color="#990000"><%=errstr%></font>&nbsp;&nbsp;<input type="button" value="重新上传" onclick="history.go(-1)"></td>
  </tr>
</table>
</body>
</html>
<%end function%>