紧急求助!在线等!问题解决马上给分。关于多文件上传问题
我用js在前台页面动态添加多个 <input type= "file "> 为什么在CS页面只能获取第一个file呢?
前台代码如下:
<body>
<form id= "form1 " method= "post " enctype= "multipart/form-data " runat= "server ">
<div>
<table width= "319 " height= "38 " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td height= "32 ">
<label> <a> 添加文件 </a> </label>
</td>
<td height= "32 " id= "td1 ">
<input type= "file " name= "file0 " id= "file0 " style= "z-index=-1 " onchange= "javascript:onchangeFile() "/>
</td>
</tr>
</table>
</form>
</body>
cs页面代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(AJax_CommonFileUpLoad));
}
if (IsPostBack)
{
UpLoad();
}
}
protected void UpLoad()
{
string[] sdr = Request.Files.AllKeys;
foreach (string str in sdr)
{
Response.Write(str+ " <br> ");
}
HttpFileCollection files = HttpContext.Current.Request.Files;
Response.Write(files.Count);
}
js代码如下:
var td=document.getElementById( "td1 ");
number+=1;
td.innerHTML+= " <input type=\ "file\ " id=\ "file "+number+ "\ " onchange= 'javascript:onchangeFile() '> ";
------解决方案--------------------不用控件也可以
用HTML file