动态添加上传文件
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="ZKSTAT.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script>
function mCreateFile(obj){
var eF;
var mName;
mFileName.innerHTML="";
if (obj.id=="File") {
for (i=0;i<mFile.children.length-1;i++)
{
if (mFile.children[i].value=="") {
mFile.removeChild(mFile.children[i])
}
else
{
mName=mFile.children[i].value.split("\\")
mFileName.innerHTML+="<div id=NameDetail title='"+mName[mName.length-1]+"'>"+mName[mName.length-1]+"</div>"
}
}
mstatus.innerHTML="总共有 <b>"+(mFile.children.length-1)+"</b> 个文件等待上传"
}
if (obj.id=="File_New") {
eF=document.createElement('<input type="file" name="File" size="23" id=File_New onpropertychange="mCreateFile(this)">')
mFile.appendChild(eF)
obj.id="File"
}
}
</script>
<style> table{ FILTER: progid:DXImageTransform.Microsoft.Shadow(direction=135,color=#999999,strength=3); }
input{ border:1px soild #000000; font-family:Verdana,Arial,宋体; font-size:12px; padding:2px; }
#mTD{ LINE-HEIGHT: 24px; }
#mFile{ width:203px; float:left; | #mFileName{ float:right; width:182px; }
#NameDetail{ overflow:hidden; width:176px; color:#000000; font-family:Verdana,Arial,宋体; font-size:12px; cursor:default; height:22px; }
#mstatus{ font-size:12px; color:#ff0000; }
</style>
</HEAD>
<body>
<form name="frm" method="post">
<div align="center">
<table border="1" width="420" style="BORDER-COLLAPSE: collapse" bordercolor="#0066cc" cellpadding="4"
bgcolor="#d0f0ff">
<tr>
<td bgcolor="#3399ff" height="26" align="center"><font color="#ffffff" size="3"><b>添加附件</b></font></td>
</tr>
<tr>
<td id="mTD">
<div id="mFile"><input type="file" name="File" size="23" id="File_New" onpropertychange="mCreateFile(this)"></div>
<div id="mFileName"></div>
<div id="mstatus">总共有 <b>0</b> 个文件等待上传</div>
</td>
</tr>
</table>
</div>
</form>
</body>
</HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script>
function mCreateFile(obj){
var eF;
var mName;
mFileName.innerHTML="";
if (obj.id=="File") {
for (i=0;i<mFile.children.length-1;i++)
{
if (mFile.children[i].value=="") {
mFile.removeChild(mFile.children[i])
}
else
{
mName=mFile.children[i].value.split("\\")
mFileName.innerHTML+="<div id=NameDetail title='"+mName[mName.length-1]+"'>"+mName[mName.length-1]+"</div>"
}
}
mstatus.innerHTML="总共有 <b>"+(mFile.children.length-1)+"</b> 个文件等待上传"
}
if (obj.id=="File_New") {
eF=document.createElement('<input type="file" name="File" size="23" id=File_New onpropertychange="mCreateFile(this)">')
mFile.appendChild(eF)
obj.id="File"
}
}
</script>
<style> table{ FILTER: progid:DXImageTransform.Microsoft.Shadow(direction=135,color=#999999,strength=3); }
input{ border:1px soild #000000; font-family:Verdana,Arial,宋体; font-size:12px; padding:2px; }
#mTD{ LINE-HEIGHT: 24px; }
#mFile{ width:203px; float:left; | #mFileName{ float:right; width:182px; }
#NameDetail{ overflow:hidden; width:176px; color:#000000; font-family:Verdana,Arial,宋体; font-size:12px; cursor:default; height:22px; }
#mstatus{ font-size:12px; color:#ff0000; }
</style>
</HEAD>
<body>
<form name="frm" method="post">
<div align="center">
<table border="1" width="420" style="BORDER-COLLAPSE: collapse" bordercolor="#0066cc" cellpadding="4"
bgcolor="#d0f0ff">
<tr>
<td bgcolor="#3399ff" height="26" align="center"><font color="#ffffff" size="3"><b>添加附件</b></font></td>
</tr>
<tr>
<td id="mTD">
<div id="mFile"><input type="file" name="File" size="23" id="File_New" onpropertychange="mCreateFile(this)"></div>
<div id="mFileName"></div>
<div id="mstatus">总共有 <b>0</b> 个文件等待上传</div>
</td>
</tr>
</table>
</div>
</form>
</body>
</HTML>