Restrict the size of file uploads in ASP.NET





5.00/5 (8 votes)
Specific directories rather than entire application: For individual uploader:int maxSize = 2097151;if (FileUpload1.HasFile &&...
Specific directories rather than entire application:
<location path="Upload">
<system.web>
<httpRuntime executionTimeout="9999" maxRequestLength="2097151" />
</system.web>
</location>
For individual uploader:
int maxSize = 2097151;
if (FileUpload1.HasFile && FileUpload1.PostedFile.ContentLeng th <= maxSize)
{
//put some logic
}