<%@ Register TagPrefix="Upload" Namespace="Mytaoyuan.Com.Upload" Assembly="Mytaoyuan.Com.Upload" %>
<%@ Page language="c#" Codebehind="upload.aspx.cs" AutoEventWireup="True" Inherits="Webdisk.upload" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
		<% @ Import Namespace="Webdisk" %>
		<link href="<%=xml.GetStyle()%>" type=text/css rel=stylesheet>
<script language=javascript>
function getUrlParam(paramName){	
	var s=location.search;
	if(s!=null){
	var sarr=s.substr(1).split("&");
	var tarr;
	for(i=0;i<sarr.length;i++){
	tarr=sarr[i].split("=");
	if(tarr.length==2&&tarr[0].toLowerCase()==paramName){
	return tarr[1];
	}
	}
	return "";
	}
}
function isNumber(oNum)
   {
  if(!oNum) return false;
  var strP=/^\d+(\.\d+)?$/;
  if(!strP.test(oNum)) return false;
  try{
  if(parseFloat(oNum)!=oNum) return false;
  }
  catch(ex)
  {
   return false;
  }
  return true;
   }
	  function setid()
	  {
	  	if (document.all.type1.style.display=='')
		{
		  str='';
		  if (!isNumber(document.form1.upcount.value)) 
		  {
		  		alert('请输入数字！');
				return false;
		  }
		  if(!document.form1.upcount.value)
		   document.form1.upcount.value=1;
		   if (document.form1.upcount.value>20)
		   {
				alert('上传数目不能大于20！');
				return false;
		   }
		   var tmp="";
		   if (getUrlParam('path')!=null) tmp+="&path="+getUrlParam('path');
		   if (getUrlParam('code')!=null) tmp+="&code="+getUrlParam('code');
		   if (getUrlParam('out')!=null) tmp+="&out="+getUrlParam('out');
		   if (getUrlParam('rtn')!=null) tmp+="&rtn="+getUrlParam('rtn');
		   window.location='upload.aspx?count='+parseInt(document.form1.upcount.value)+tmp;
		 }
		 else if (document.all.type3.style.display=='')
		 {
		  str='';
		  if(!document.form1.upcount.value)
		   document.form1.upcount.value=1;
		   if (document.form1.upcount.value>20)
		   {
				alert('添加数目不能大于20！');
				return false;
		   }
		  for(i=1;i<=document.form1.upcount.value;i++)
			 str+='标题：<INPUT class=kuan id=Text3 type=text name=url>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;网址：<INPUT class=kuan id=Text1 type=text name=url><br>';
		  document.getElementById("upid1").innerHTML=str+'<br>';
		 }
		 else
		 {
		  str='';
		  if(!document.form1.upcount.value)
		   document.form1.upcount.value=1;
		   if (document.form1.upcount.value>20)
		   {
				alert('添加数目不能大于20！');
				return false;
		   }
		  for(i=1;i<=document.form1.upcount.value;i++)
			 str+='下载地址：<INPUT class=kuan id=textBoxFileURL type=text name=textBoxFileURL size=52>&nbsp;&nbsp;文件描述：<input id=note2 name=note2 type=text class=kuan size=30><br>';
		  document.getElementById("upid2").innerHTML=str+'<br>';
		 }
	  }
	  function filenote()
	  {
		var valueStr = "";
		var inputs = document.getElementsByTagName("input");
		for(var i = 0; i < inputs.length; i++)
		{
			
		if(inputs[i].name == "note")
		{
		valueStr += inputs[i].value + ",";
		}
		}
		document.all.hidurl.value=valueStr;
	  }
	  function outlink()
	  {
		var valueStr = "";
		var inputs = document.getElementsByTagName("input");
		for(var i = 0; i < inputs.length; i++)
		{
			
		if(inputs[i].name == "url")
		{
		valueStr += inputs[i].value + ",";
		}
		}
		document.all.hidurl.value=valueStr;
	  }
	  function show1()
	  {
	  	document.all.type1.style.display='';
		document.all.type2.style.display='';
		document.all.type3.style.display='none';
		document.all.type4.style.display='none';
		document.all.type5.style.display='none';
		document.all.type6.style.display='none';
	  }
	  function show2()
	  {
	  	document.all.type1.style.display='none';
		document.all.type2.style.display='none';
		document.all.type3.style.display='';
		document.all.type4.style.display='';
		document.all.type5.style.display='none';
		document.all.type6.style.display='none';
	  }
	  function show3()
	  {
	  	document.all.type1.style.display='none';
		document.all.type2.style.display='none';
		document.all.type3.style.display='none';
		document.all.type4.style.display='none';	
		document.all.type5.style.display='';
		document.all.type6.style.display='';
	  }
function EditOpt()
{
	Webdisk.upload.EditOpt(document.all.autorename.checked);
}
			</script>

<style type=text/css>.STYLE1 { COLOR: #0000ff }
	.ProgressBar { BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: 0px; WIDTH: 100%; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; HEIGHT: 3em }
	</style>
<title>上传文件</title></HEAD>
<body>
<form id=form1 method=post runat="server"><FONT face=宋体></FONT><br>
<TABLE cellSpacing=0 cellPadding=0 width="98%" align=center>
  <TR>
    <TD width=5 background=pics/wenbenkuan_02.gif><IMG height=5 src="pics/wenbenkuan_01.gif" width=5 ></TD>
    <TD width=874 background=pics/wenbenkuan_02.gif><IMG height=5 src="pics/wenbenkuan_02.gif" width=5 ></TD>
    <TD><IMG height=5 src="pics/wenbenkuan_03.gif" width=5 ></TD></TR>
  <TR>
    <TD background=pics/wenbenkuan_04.gif>&nbsp;</TD>
    <TD class=tablebg background=pics/wenbenkuan_05.gif>
      <TABLE width="100%">
        <TR>
          <TD class=tabletop width="100%"><IMG src="pics/pick.gif" align=absMiddle > 上传文件&nbsp;&nbsp;&nbsp;&nbsp;<A href="javascript:history.go(-1);" ><IMG src="pics/link_back.gif" align=absMiddle border=0 ></A></TD></TR>
        <TR class=tablebg>
          <TD>
            <TABLE cellSpacing=0 cellPadding=4 width="100%" border=0 
            >
              <TBODY>
              <TR>
                <TD>
                  <H4>路径: <asp:label id=txtpath runat="server"></asp:label></H4>类型： 
                  <input id=click1 onclick=show1() type=radio CHECKED value=1 
                  name=optshow> <label for=click1 
                  >上传文件</label> <input id=click2 
                  onclick=show2() type=radio value=2 name=optshow 
                  > <label for=click2 
                  >链接网址</label> <input id=click3 
                  onclick=show3() type=radio value=2 name=optshow 
                  > <label for=click3 
                  >外部下载</label> <br><BR 
                  >需上传的个数 : <input class=kuan id=upcount 
                  type=text size=7 value=5 name=upcount> <input class=kuan onclick=setid(); type=button value=" 设 定 " name=Button> 
                  <INPUT id=autorename type=checkbox CHECKED name=autorename 
                   runat="server" onChange="EditOpt();"> <label for=autorename 
                  ><span class=STYLE1 
                  >重名文件自动更名</span></label> <BR 
                  ></TD></TR>
              <TR id=type1>
                <TD id=upid>
                  <P><UPLOAD:INPUTFILE id=UpLoad1 runat="server" CssClass="kuan" Width="400px"></UPLOAD:INPUTFILE>&nbsp;&nbsp;文件描述：<input name=note type=text 
                  class=kuan size="30">
                  <br 
                  ><asp:placeholder id=Panel1 
                   
              runat="server"></asp:placeholder></P></TD></TR>
              <TR id=type2>
                <TD>
                  <table width="100%" border=0>
                    <tr>
                      <td><UPLOAD:PROGRESSBAR 
                        id=inlineProgressBar runat="server" 
                        inline="true" 
                      Triggers="btn_upload"></UPLOAD:PROGRESSBAR></td></tr>
                    <tr>
                      <td width="31%"><INPUT class=btn id=btn_upload type=button value=" 上 传 " name=btn_upload runat="server" onserverclick="btn_upload_ServerClick"> 
                        &nbsp; <INPUT class=btn id=btn_return onclick=javascript:history.go(-1); type=button value=" 返 回 " name=btn_return> 
<asp:label id=notype runat="server"></asp:label><INPUT 
                        id=Hidpath2 type=hidden size=1 name=Hidpath 
                         runat="server"></td></tr></table>
                    <INPUT id=maxsize type=hidden name=maxsize 
                   runat="server"> </p>
                  <p></p></TD></TR>
              <TR id=type3 style="DISPLAY: none">
                <TD id=upid1>
                  <P>标题： <INPUT class=kuan id=Text3 
                  type=text name=url> &nbsp;&nbsp;网址： 
                  <INPUT class=kuan id=Text1 type=text name=url 
                  > </P></TD></TR>
              <TR id=type4 style="DISPLAY: none">
                <TD><INPUT class=btn id=Submit onclick=outlink(); type=button value=" 添 加 " name=Submit runat="server" onserverclick="Submit_ServerClick"> 
                  &nbsp;<INPUT class=btn id=btn_return1 onclick=javascript:history.go(-1); type=button value=" 返 回 " name=btn_return1> 
                  <INPUT id=hidurl type=hidden name=hidurl 
                  runat="server"></TD></TR>
              <TR id=type5 style="DISPLAY: none">
                <TD id=upid2>
                  <P>下载地址：<INPUT class=kuan 
                  id=textBoxFileURL type=text size=52 name=textBoxFileURL 
                   runat="server">&nbsp;&nbsp;文件描述：<input id=note2 name=note2 type=text class=kuan size="30">
</P></TD></TR>
              <TR id=type6 style="DISPLAY: none">
                <TD><INPUT class=btn id=progressStartButton onclick=StartEverything(this); type=button value=" 下 载 " name=progressStartButton> 
                  &nbsp;<INPUT class=btn id=btn_return2 onclick=javascript:history.go(-1); type=button value=" 返 回 " name=btn_return1> 
                  （填写外部要下载到空间中的文件地址，为直接下载地址，如：http://www.xxx.com/xxx.zip） 
                  <p>
                  <p><asp:literal id=progressVariables 
                   runat="server"></asp:literal></p>
                  <div id=progressNotices 
                  style="FONT-WEIGHT: bold; FONT-SIZE: 12px; FONT-FAMILY: Verdana; HEIGHT: 14px" 
                  ></div>
                  <div id=progressBarArea style="DISPLAY: none" 
                  >
                  <div 
                  style="BORDER-RIGHT: gray 1px inset; PADDING-RIGHT: 1px; BORDER-TOP: gray 1px inset; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; MARGIN: 14px; BORDER-LEFT: gray 1px inset; PADDING-TOP: 1px; BORDER-BOTTOM: gray 1px inset" 
                  ><FONT face=宋体></FONT>
                  <div id=progressBar 
                  style="WIDTH: 0%; COLOR: navy; HEIGHT: 22px; BACKGROUND-COLOR: navy" 
                  ></div></div><asp:literal id=progressAlert 
                   
                  runat="server"></asp:literal></div><iframe id=progressIFrame 
                  style="POSITION: absolute" name=progressIFrame 
                  src="about:blank" frameBorder=0 width=0 scrolling=no 
                  height=0></iframe>
                  <DIV></DIV>
                  <DIV 
        ></DIV></TD></TR></TBODY></TABLE></TD></TR></TABLE></TD>
    <TD width=5 background=pics/wenbenkuan_06.gif><IMG height=5 src="pics/wenbenkuan_06.gif" width=5 ></TD></TR>
  <TR>
    <TD background=pics/wenbenkuan_08.gif><IMG height=5 src="pics/wenbenkuan_07.gif" width=5 ></TD>
    <TD background=pics/wenbenkuan_08.gif><IMG height=5 src="pics/wenbenkuan_08.gif" width=5 ></TD>
    <TD><IMG height=5 src="pics/wenbenkuan_09.gif" width=5 ></TD></TR></TABLE></form>
<script language=javascript>
	function getUrlParam(paramName){	
		var s=location.search;
		if(s!=null&&s.length>1){
		var sarr=s.substr(1).split("&");
		var tarr;
		for(i=0;i<sarr.length;i++){
		tarr=sarr[i].split("=");
		if(tarr.length==2&&tarr[0].toLowerCase()==paramName){
		return tarr[1];
		}
		}
		return null;
		}
	}
	function StartEverything(callingButton){
		if (document.getElementById('progressStartButton').value ==' 停 止 ')
		{
			document.getElementById('progressStartButton').value =' 下 载 ';
			document.getElementById('progressNotices').innerHTML='';
			document.getElementById('progressBarArea').style.display = 'none';
			window.frames['progressIFrame'].location.href = 'about:blank';
		}
		else
		{
			document.getElementById('progressNotices').innerHTML='正在处理，请稍候……';
			window.frames['progressIFrame'].location.href = UniqueUrl(AppendArgument("downworker.aspx"));
		}
	}
	var objMessage = null;
	var objBar = null;
	var maxReached = false;
	function SetProgress(percentage, message){
		if(percentage <= 100){
			if(objMessage == null){
				objMessage = document.getElementById('progressNotices');
			}
			if(objBar == null){
				objBar = document.getElementById('progressBar');
			}
			if(message != null && message != ''){
				objMessage.innerHTML = message;
			}
			if(percentage > 0){
				objBar.innerHTML = '.';
			}else{
				objBar.innerHTML = '';

			}
			objBar.style.width = percentage.toString() + '%';
			if(percentage == 100){
				SetDisplay(false);
			}
		}else{
			maxReached = true;
		}
	}
	function SetDisplay(progressIsRunning){
		var progressBarArea = document.getElementById('progressBarArea');
		progressBarArea.style.display = (progressIsRunning ? 'block' : 'none');
		document.getElementById('progressStartButton').value = (progressIsRunning ? ' 停 止 ' : ' 下 载 ');
	}
	function Say(message){
		if(message == null || message == ''){
			message = '(null)';
		}
		alert(message);
	}
	function AppendArgument(url){
		if(url.indexOf('?') > 0){
			url += '&';
		}else{
			url += '?';
		}
		url += "file";
		var argValue = '';
		var argNote='';
		var inputs = document.getElementsByTagName("input");
		for(var i = 0; i < inputs.length; i++)
		{
			if(inputs[i].id == "textBoxFileURL") argValue += inputs[i].value + ",";
			if(inputs[i].id == "note2") argNote += inputs[i].value + ",";
		}
		if(argValue != null && argValue != ''){
			if(url.indexOf('=') != (url.length - 1)){
				url += '=';
			}
			url += escape(argValue);
		}
		else
		{
			alert('请输入下载文件的外部地址！');
			return;
		}
		url +='&path='+getUrlParam('path');
		url += '&note='+escape(argNote);
		if (getUrlParam('out')!=null) url +='&out='+getUrlParam('out');
		if (document.all.autorename.checked) url +='&auto=1';
		SetDisplay(true);
		return url;
	}
	function UniqueUrl(url){
		var randomNum, uniqifier;
		if(url == null || url == ''){
			url = 'UrlUndefined';
		}else if(url.indexOf('Unique') > 0){
			randomNum = Math.random();
			url = ReplaceArgumentValue(url, 'Unique', randomNum.toString().substr(2));
		}else{
			randomNum = Math.random();
			uniqifier = 'Unique=' + randomNum.toString().substr(2);
			if(url.indexOf('?') > 0){
				url += '&' + uniqifier;
			}else{
				url += '?' + uniqifier;
			}
		}
		return url;
	}
	function ReplaceArgumentValue(searchArgs, argName, newArgValue){
		var newSearchArgs;
		argName += '=';
		var indexStart = searchArgs.indexOf(argName);
		if(indexStart >= 0){
			var indexEnd = searchArgs.indexOf('&', indexStart);
			newSearchArgs = searchArgs.substr(0, indexStart + argName.length);
			newSearchArgs += newArgValue;
			if(indexEnd > indexStart){
				newSearchArgs += searchArgs.substr(indexEnd);
			}
			return newSearchArgs;
		}else{
			return searchArgs;
		}
	}
</script>

	</body>
</HTML>
