解决HttpContext.Current.Request.Files返回的文件个数不正确问题
2009-06-24 09:38
597 查看
昨天工作中出现了这样一个问题,明明页面上我选择了3个文件要上传,但是
执行HttpFileCollection files = HttpContext.Current.Request.Files;
file返回的结果总是1。非常纳闷,到底是为什么呢?为什么呢?
今天一早无意中发现一个可能导致该错误的原因,结果一试,果然如此啊~~~
解决:必须为file控件添加Name属性
function newUpload(obj)
{
if(obj.value=="")
{
return;
}
else
{
var str = '<br/><input type="file" onchange="javascript:newUpload(this);" runat="server" name="file" />';
document.getElementById('Upload1').insertAdjacentHTML("beforeEnd",str);
}
}
执行HttpFileCollection files = HttpContext.Current.Request.Files;
file返回的结果总是1。非常纳闷,到底是为什么呢?为什么呢?
今天一早无意中发现一个可能导致该错误的原因,结果一试,果然如此啊~~~
解决:必须为file控件添加Name属性
function newUpload(obj)
{
if(obj.value=="")
{
return;
}
else
{
var str = '<br/><input type="file" onchange="javascript:newUpload(this);" runat="server" name="file" />';
document.getElementById('Upload1').insertAdjacentHTML("beforeEnd",str);
}
}
相关文章推荐
- HttpContext.Current.Request.Files后台取不到值的解决方法
- HttpContext.Current.Request.Files后台取不到值的解决方法
- HttpContext.Current.Request.Files后台取不到值的解决方法
- HttpContext.Current.Request.Files后台取不到值的解决方法 [转]
- HttpContext.Current.Request.QueryString.AllKeys 返回的大小写, 飘忽不定。
- 解决HttpContext.User.IsInRole() 永远返回false的问题
- 使用Nginx代理,HttpContext.Current.Request.Url.Host.ToString()获取地址是原地址的问题。
- 异步 HttpContext.Current实现取值的方法(解决异步Application,Session,Cache...等失效的问题)
- HttpContext.Current.Cache使用文件依赖问题
- 集成平台自动登入+C# Login控件,造成的HttpContext.Current.User.Identity.Name 为空问题解决方案
- 解决Context.getExternalFilesDir(null)返回null造成java.lang.NullPointerException的问题
- 完美解决由NSURLConnection或者ASIHttpRequest返回的中文乱码问题。
- 返回上一页面地址 HttpContext.Current.Request.UrlReferrer.ToString()
- 异步 HttpContext.Current实现取值的方法(解决异步Application,Session,Cache...等失效的问题)
- 异步 HttpContext.Current实现取值的方法(解决异步Application,Session,Cache...等失效的问题)
- 异步 HttpContext.Current实现取值的方法(解决异步Application,Session,Cache...等失效的问题)
- 文件上传 content-type:application/json System.Web.HttpContext.Current.Request.InputStream 读取不到数据
- HttpContext.Current.Request.Files
- 解决ajax XMLHttpRequest 跨域上传文件失败问题