Solved

asp.net not stopping image upload size.

Posted on 2014-02-12
3
343 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
ID: 39854290
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
ID: 39857275
how can i do this with javascript?
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39857428
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 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