Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

asp.net not stopping image upload size.

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
rivkamak
Asked:
rivkamak
  • 2
1 Solution
 
CodeCruiserCommented:
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
 
rivkamakAuthor Commented:
how can i do this with javascript?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now