Asp.net中,上传文件的默认大小是4096 KB,也就是4M,不过你可以在Web.config中更改这个数据

<httpRuntime maxRequestLength="10240"

         useFullyQualifiedRedirectUrl="true"

         executionTimeout="100"/>


那么此时就是
10M的文件,当然你也可以把它修改的更大,但是不管改成多大都会有个极限,如果用户上传的文件比这个值大,就会出现程序Catch不到的异常因为这个是在运行时才能够监测,如下的错误:

Action canceled

 

Internet Explorer was unable to link to the Web page you requested. The page might be temporarily unavailable.

Please try the following:

  • Click the Refresh button, or try again later.

  • If you have visited this page previously and you want to view what has been stored on your computer, click File, and then click Work Offline.

  • For information about offline browsing with Internet Explorer, click the Help menu, and then click Contents and Index.

 

虽然你在代码中控制了大小,不过程序在运行到这里之前已经崩溃了

// Attachment size is too larger

if(PersonPhoto.PostedFile.ContentLength > 10240)

{

    this.lblError.Text = "The file you selected is larger than 10MB";

    this.lblError.Visible = true;

    return;

}

大家有什么办法嘛?ASP.NET中关于上传附件的大小设置问题

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
  • 2021-09-06
  • 2021-07-18
  • 2021-06-21
猜你喜欢
  • 2022-01-28
  • 2022-12-23
  • 2022-12-23
  • 2022-01-24
相关资源
相似解决方案