<%guidedisplay=1%>
<!--#include file="admin_start.asp" -->
<!--#include file="../inc/class_upload.asp"-->
<%
dim filelx
dim filepath
dim fileExt
dim filesize
dim upload
dim file
dim filename

set upload=new upload_file
tt=trim(upload.form("key"))
'response.write tt
'response.end

if Session("FB_EM_1_ACC_uppath_"&tt)="" then
	response.write  "<script>alert('上传路径为空！');history.back(-1);</script>"
	response.end
end if

if instr(1,Session("FB_EM_1_ACC_uppath_"&tt),".")>0 and instr(1,Session("FB_EM_1_ACC_uppath_"&tt),"../")=0 then
    Session("FB_EM_1_ACC_uppath_"&tt)=""
	response.write  "<script>alert('上传路径中不能含有“.”轻核对！');history.back(-1);</script>"
	response.end
end if

filepath=Session("FB_EM_1_ACC_uppath_"&tt)

	
for each formName in upload.File

	set file=upload.File(formName)
	 
	fileExt=lcase(file.FileExt)
	
	set rs_t=conn.execute("select * from sys_file_list where file_lx='"&fileExt&"' and file_open=1 ")
	if rs_t.eof then
		set file=nothing
		set upload=nothing
		response.write  "<script>alert('您上传的文件格式没有注册或者被停止！');history.back(-1);</script>"
		response.end
	else
		MySys.GradeCheck(rs_t("file_customer_grade"))
		
		if file.filesize<(rs_t("file_minsize")*1024) then
		   set file=nothing
		   set upload=nothing
		   response.write  "<script>alert('您上传得文件大小小于最小限制[ "&rs_t("file_minsize")&" KB ]！');history.back(-1);</script>"
		   response.end
		End If
		
		if file.filesize>(rs_t("file_maxsize")*1024) then
		   set file=nothing
		   set upload=nothing
		   response.write  "<script>alert('您上传得文件大小大于最大限制[ "&rs_t("file_maxsize")&" KB ]！');history.back(-1);</script>"
		   response.end
		End If
	end if

	if not MySys.check.CheckDir(server.mappath(filepath)) then MySys.check.MakeNewsDir(server.mappath(filepath))
	'///////////////////////////////////////filename
	 randomize
	 ranNum=int(90000*rnd)+10000
	 filename=MySys.functions.EncodeMd5(year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum,16)&"."&fileExt
	 filename=ucase(filename)
	 filename=filepath&"/"&filename
	'///////////////////////////////////////
	 if file.FileSize>0 then         ''è?1? FileSize > 0 ?μ?÷óD???têy?Y
		 file.SaveToFile Server.mappath(FileName)
		 if upload.form("type")<>"f" then 
		 response.write "<script>window.opener.document."&upload.form("FormName")&"."&upload.form("EditName")&".value='"&replace(FileName,"../","")&"'</script>"
		 else
		 response.write "<script>parent.document."&upload.form("FormName")&"."&upload.form("EditName")&".value='"&replace(FileName,"../","")&"'</script>"
		 end if
		 'response.write "<script>window.opener.document."&upload.form("FormName")&"."&upload.form("EditName")&".disabled=1</script>"
	 end if
	 set file=nothing
next
Session("FB_EM_1_ACC_uppath_"&tt)=""

if upload.form("type")<>"f" then 
%>
<script language="javascript">
window.alert("文件上传成功！请不要修改地址栏内的地址！");
window.close();
</script>
<%else%>
文件上传成功！请不要修改地址栏内的地址！
<%
end if
set upload=nothing
%>
<!--#include file="admin_end.asp" -->