'ASP.NET file upload size restriction
I want to restrict users from uploading file sizes of more than 4MB, is there any way to do this without modifying the configuration file? I tried the code below to validate the file and response redirect but was still not able to make it. As long as I upload a file that is larger than 4MB it crashes when I click submit.
if(FileUpload1.PostedFile.ContentLength > 1234)
{
FileUpload1.Attributes.Clear();
Response.Redirect("Main.aspx");
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
