Message when it exceeds FileUpload size

0

I'm trying to put a message to when it exceeds the size of the file in FileUpload, I've already packed it inside the web config, however it always returns me the following error:

  

Maximum request length exceeded.

I saw this example on the internet, I tried to adapt it to my code but the above error continues to appear:

<script type ="text/javascript">
        $(function () {
            $('<%= Anexo.ClientID %>').change(function () {

                //because this is single file upload I use only first index
                var f = this.files[0]

                //here I CHECK if the FILE SIZE is bigger than 8 MB (numbers below are in bytes)
                if (f.size > 8388608 || f.fileSize > 8388608) {
                    //show an alert to the user
                    alert("Allowed file size exceeded. (Max. 8 MB)")

                    //reset file upload control
                    this.value = null;
                }
            })
        });
    </script>

I have already seen several examples on the internet, I have tried in many ways, I have researched here in the forum and others on the internet, but no example is occurring the message that the size has been exceeded.     

asked by anonymous 14.07.2017 / 20:22

1 answer

0

In fact this example worked, I was just missing the # here: $ ('# <% = Attachment.ClientID%>') and it worked.

    
20.07.2017 / 14:12