Q:代码如下:
protected void btn_upload_Click(object sender, EventArgs e)
{
HttpFileCollection files = Request.Files;
for (int iFile = 0; iFile < files.Count; iFile++)
{
HttpPostedFile postedFile = files[iFile];
string fileName;
fileName = System.IO.Path.GetFileName(postedFile.FileName);
Response.Write(fileName);
}
}
就是显示上传控件中文件的名字,在FF3下运行OK,在IE7下运行就会报错。可这个页面上个月做项目的时候还没有问题,IIS真是太奇怪了。在网上找了一下原因,最后发现是少了这行?
<httpRuntime executionTimeout="60" maxRequestLength="100000" />
可为什么前段时间不会报错呢.
<input id="File1" type="file" name="File11" />而且在前台页面html file控件必须加上name属性。不然在后台得不到值。
protected void btn_upload_Click(object sender, EventArgs e)
{
HttpFileCollection files = Request.Files;
for (int iFile = 0; iFile < files.Count; iFile++)
{
HttpPostedFile postedFile = files[iFile];
string fileName;
fileName = System.IO.Path.GetFileName(postedFile.FileName);
Response.Write(fileName);
}
}
就是显示上传控件中文件的名字,在FF3下运行OK,在IE7下运行就会报错。可这个页面上个月做项目的时候还没有问题,IIS真是太奇怪了。在网上找了一下原因,最后发现是少了这行?
<httpRuntime executionTimeout="60" maxRequestLength="100000" />
可为什么前段时间不会报错呢.
<input id="File1" type="file" name="File11" />而且在前台页面html file控件必须加上name属性。不然在后台得不到值。
ASP.NET文件上传问题
本文描述了一个ASP.NET项目中文件上传功能的问题,在Firefox 3下正常工作,但在Internet Explorer 7下遇到错误。作者发现通过增加<httpRuntime>配置中的maxRequestLength属性可以解决该问题,并且指出了HTML文件输入控件需要设置name属性。
1250

被折叠的 条评论
为什么被折叠?



