VS2005 asp.net(C#)上传问题. ---寻找CSDN牛人
各位强淫:
小弟最近做asp.net C#的上传时,有问题一直解决不了,各位牛人帮忙啊.
aspx内部分代码:
<title> 多文件上传 </title>
<script language= "JavaScript ">
function addFile()
{
var str = ' <INPUT type= "file " size= "50 " NAME= "File "> '
document.getElementById( 'MyFile ').insertAdjacentHTML( "beforeEnd ",str)
}
</script>
<form id= "form2 " method= "post " runat= "server " enctype= "multipart/form-data ">
<div align= "center ">
<h3> 多文件上传 </h3>
<P id= "MyFile "> <INPUT type= "file " size= "50 " NAME= "File "> </P>
<P>
<input type= "button " value= "增加(Add) " onclick= "addFile() ">
<input onclick= "this.form.reset() " type= "button " value= "重置(ReSet) ">
<asp:Button Runat= "server " Text= "开始上传 " ID= "UploadButton "> </asp:Button>
</P>
<P>
<asp:Label id= "strStatus " runat= "server " Font-Names= "宋体 " Font-Bold= "True " Font-Size= "9pt "
Width= "500px " BorderStyle= "None " BorderColor= "White "> </asp:Label>
</P>
</div>
</form>
aspx.cs内部分代码:
/// '遍历File表单元素
HttpFileCollection files = HttpContext.Current.Request.Files;
新建工程,上面的files是有值的.但放在自己的工程里,files的COUNT一直是0,
怎么回事啊?各位帮帮忙.
------解决方案--------------------//--刚才测试了下没问题啊. 估计是你代码中其他地方有问题.
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "testMoreUpload.aspx.cs " Inherits= "testMoreUpload " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transition