Click here to Skip to main content
Click here to Skip to main content
Alternative Tip/Trick

Tagged as

Restrict the size of file uploads in ASP.NET

, 29 Jul 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
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

}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Monjurul Habib
Software Developer (Senior)
Bangladesh Bangladesh
A life-long-learner, maker and soft music fan. Likes building things to solve problems. Lives in Dhaka with wife and wonderful, smart kid and works as a Senior Software Engineer in applications architecture team.
 
He has years of successful records serving mid and large scale .NET applications. Have a wide range of experience working in domestic and international client environment. Expertise in different areas of software development life cycles and Software Architecture.
 
I am always looking for new information and value your feedback (especially where I got something wrong!).
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
Questionlogic PinmemberAyesha Atif23-Sep-13 13:41 
GeneralMy vote of 5 PinmemberMaksud Saifullah Pulak26-Feb-13 21:45 
GeneralRe: My vote of 5 PinmemberMonjurul Habib27-Feb-13 9:44 
GeneralRe: My vote of 5 PinmemberAyesha Atif23-Sep-13 13:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141216.1 | Last Updated 29 Jul 2011
Article Copyright 2011 by Monjurul Habib
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid