| 发表于:2007-08-15 18:15:30 楼主 |
我用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() '> "; |
|
|
|
|