<!--#include file="Inc/Const.asp" -->
<%
' 取消缓存
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
' 建立上传顺序号码，为建立上传进度数据文件做准备
Dim UpLoaddingDate
Randomize Timer()
UpLoaddingDate = iXs.FormatTime(Now(), 5) & Clng(1000 + Rnd()*8999)

Dim ObjUpType, bgColor, Wid, MaxNum, sAllowExt

' 背景颜色
bgColor = iXs.ReqStr("bgColor")
If bgColor = "" Then bgColor = "buttonface"

' 文件类型，因为《爱雪儿图文管理系统》将附件分类文章、友情连接、公告、产品展示等等的模块分类，所以加入此参数，您可以去掉
ObjUpType = iXs.ReqNum("ObjUpType")
If ObjUpType = "" Then ObjUpType = 0

' 这是附件要应用到的位置
' 在《爱雪儿图文管理系统》中的应用方法是：例如在修改编号为22的文章的时候可以将此值设置为22，这样在文章提交的时候就不需要再次检测了。
' 意义不大，可以去掉
Wid = iXs.ReqNum("Wid")
If Wid = "" Then Wid = 0

' 下面就是《爱雪儿图文管理系统》根据不同的系统应用而获取不同的系统设置，这里是无效的，仅仅是演示
Select Case ObjUpType
	Case 0 ' 文章系统
		MaxNum = iXs.Sys_Info(48)
		sAllowExt = iXs.Sys_Info(35)
	Case 1 ' 友情连接系统
		MaxNum = iXs.Sys_Info(49)
		sAllowExt = iXs.Sys_Info(39)
	Case 2 ' 友情连接系统
		MaxNum = iXs.Sys_Info(59)
		sAllowExt = iXs.Sys_Info(62)
	Case Else ' 默认
		MaxNum = 1
		sAllowExt = "bmp/doc/gif/jpg/jpeg/wma/wmv/mid/mp3/mpg/dat/png/rar/swf/torrent/txt/zip"
End Select
sAllowExt = "bmp/doc/gif/jpg/jpeg/wma/wmv/mid/mp3/mpg/dat/png/rar/swf/torrent/txt/zip/pdf"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>上传接口</title>
<style type="text/css">
	@charset "gb2312";
	body,td,th {color: #000000;font: 12px Tahoma, "宋体";}
	body{margin:0px; background-color:<% = bgColor %>;}
	input{Border: 1px solid #000000;BackGround-Color: buttonface;Color: #000000;height:17px;font: 12px Tahoma, "宋体";}
</style>
<script language="javascript1.2">
<!--
	if(top.location == self.location){
		//alert("请不要非法调用此文件！");
		//top.location="<% = iXs.Sys_Info(5) %>";
	}
-->
</script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="4" cellspacing="0">
  <tr><td><fieldset><legend>文件上传</legend>
	<TABLE width="50%" BORDER="0" align="center" CELLPADDING="2" CELLSPACING="0">
		<Form name="UpLoad_Form" id="UpLoad_Form" method="post" onsubmit="return apply()" ACTION="UpLoadPost.asp?bgColor=<% = bgColor %>&Action=1&ObjUpType=<% = ObjUpType %>&Wid=<% = Wid %>&UpLoaddingDate=<% = UpLoaddingDate %>" ENCTYPE="multipart/Form-data">
		<TR style="display:none"> 
		  <TD width="90%" align="left" style="display:none"><INPUT TYPE="text" id="upcount" NAME="upcount" VALUE="1" size="4">
			<INPUT TYPE="button" id="setids" NAME="setids" VALUE=" 设 定 " onClick="setid();">
			<input type="hidden" name="Files">			</TD>
		  <TD width="10%" align="right"></TD>
		</TR>
		<TR>
		  <TD colspan="2" align="left" id="upid"><input name="strFile1" type="file" id="strFile1" style="width:200" onChange="return CheckUploadForm();" >&nbsp;&nbsp;<INPUT TYPE="submit" id="submit" NAME="submit" VALUE=" 上 传 " onClick="return CheckUploadForm();"></TD>
		</TR>
		<TR>
		  <TD colspan="2" align="left" id="upid">&nbsp;</TD>
		</TR>		
		</Form>
	</TABLE>
  </fieldset>
</td></tr></table>
<script language="javascript1.2">
<!--
	var iframeids = ["UpLoad_Ad"];
	var iframehide = "yes";
	var sAllowExt = "<% = Replace(sAllowExt, "/", "|") %>"
	var i = 0;
	var n = 0
	var Obj01 = window.UpLoad_Form.upcount;
	var Obj02 = document.getElementById("Files");
	function dyniframesize(){
		var dyniframe=new Array();
		for (i=0; i<iframeids.length; i++){
			if (parent.document.getElementById){
				dyniframe[dyniframe.length] = parent.document.getElementById(iframeids[i]);
				if (dyniframe[i] && !window.opera){
					dyniframe[i].style.display="block";
					if (dyniframe[i].contentDocument && dyniframe[i].contentDocument.body.offsetHeight){
						dyniframe[i].height = dyniframe[i].contentDocument.body.offsetHeight;
					}else if (dyniframe[i].Document && dyniframe[i].Document.body.scrollHeight){
						dyniframe[i].height = dyniframe[i].Document.body.scrollHeight;
					}
				}
			}
			if ((parent.document.all || parent.document.getElementById) && iframehide=="no"){
				var tempobj=parent.document.all? parent.document.all[iframeids[i]] : parent.document.getElementById(iframeids[i]);
				tempobj.style.display="block";
			}
		}
	}
	
	function setid(){
		str='';
		if(!Obj01.value){Obj01.value=1;}
		if(Obj01.value==0){Obj01.value=1;}
		if(Obj01.value><% = MaxNum %>){
			alert("您最多只能同时上传 <% = MaxNum %> 个文件!");
			Obj01.value = <% = MaxNum %>;
			setid();
		}
		else{
			for(n=1;n<=Obj01.value;n++){
				str+='文件'
				if(n<10)(str+=0)
				str+=n+'：<input type="file" name="strFile'+n+'" id="strFile'+n+'" style="width:200" onChange="return CheckUploadForm();"><br>';
				window.upid.innerHTML=str;
			}
			dyniframesize();
		}
	}
	function apply(){
		try{
			// 检测并禁用文件域表单
			for(n=1;n<=Obj01.value;n++){
				document.getElementById("strFile" + n).readOnly = true;
			}
			// 禁用提交表单
			document.getElementById("submit").disabled = true;
			// 禁用数目设置和按钮
			document.getElementById("upcount").disabled = true;
			document.getElementById("setids").disabled = true;
			// 打开进度条对话框
			return WinPop("iXs_UpViewBar.asp?UpLoaddingDate=<% = UpLoaddingDate %>&Files=" + Obj02.value, 430, 165);
		}
		catch(e){};
	}
	// 生成弹出窗口
	function WinPop(url, width, height){
		window.showModelessDialog(url, "UpLoadPross",'dialogWidth=' + width + 'px; dialogHeight=' + height + 'px; resizable=no; help=no; scroll=no; status=no;') 
	}
	// 是否有效的扩展名
	function IsExt(url, opt){
		var sTemp;
		var b=false;
		var s=opt.toUpperCase().split("|");
		for (var i=0;i<s.length ;i++ ){
			sTemp=url.substr(url.length-s[i].length-1);
			sTemp=sTemp.toUpperCase();
			s[i]="."+s[i];
			if (s[i]==sTemp){
				b=true;
				break;
			}
		}
		return b;
	}
	// 检测上传表单 检测扩展名是否有效
	function CheckUploadForm() {
		var Obj;
		Obj02.value = ""
		for(n=1;n<=Obj01.value;n++){
			Obj = document.getElementById("strFile" + n);
			if(!IsExt(Obj.value, sAllowExt) && Obj.value!=""){
				alert("提示：\n\n第 【" + n + "】 个文件无效！\n\n请选择一个有效的文件，\n支持的格式有：\n" + sAllowExt);
				Obj.style.border = "2px solid #FF0000";
				return false;
			}
			if(Obj02.value==""){
				Obj02.value = Obj.value;
			}else{
				Obj02.value += "|" + Obj.value;
			}
			Obj.style.border = "1px solid #000000";
		}
		return true
	}
	// 初始化框架高度
	dyniframesize();
//-->
</script>
</BODY>
</HTML>