Solved

asp.net not stopping image upload size.

Posted on 2014-02-12
3
340 Views
Last Modified: 2014-02-20
I have a  simple asp.net form that is uploading an image.
Even though I put the max-file-size in my form, it's not stopping the page from working and the user just gets an error.
how can I stop the script from erroring and ask the user to retry their.
I am using asp.net 2.0
Thank you

  <form id="form1" runat="server">
            <div>
              <asp:FileUpload ID="FileUpload1" name="FileUPload1" runat="server" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ControlToValidate="FileUpload1" ErrorMessage="File is required"></asp:RequiredFieldValidator>
              <br /><input type="hidden" name="MAX_FILE_SIZE" value="100000" />
              <br />
              <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" 
         Text="Upload File" />          
              &nbsp;<br />
              <br />
              <asp:HiddenField ID="id2" runat="server"   />
              <asp:Label ID="Label1" runat="server"></asp:Label>
            </div>
      </form>

Open in new window

0
Comment
Question by:rivkamak
  • 2
3 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
You cannot check the size of the file before it is uploaded to the server. You can only upload to the server if the file is less that the size allowed on server. You would need to use Javascript or other client side technique to achieve this.
0
 

Author Comment

by:rivkamak
Comment Utility
how can i do this with javascript?
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
Comment Utility
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now