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:
|
// 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;
}
大家有什么办法嘛?