Solved

asp.net not stopping image upload size.

Posted on 2014-02-12
3
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

615 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