Message when it exceeds Fileupload size

Asked

Viewed 378 times

0

I’m trying to put a message for when it exceeds the file size in Fileupload, already arranged inside the web config, but always returns me the following error:

Maximum request size exceeded.

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

<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 seen several examples on the Internet, I have tried several ways, I have searched here on the forum and others on the Internet, but no example is occurring the message that the size was exceeded.

1 answer

0


Actually this example worked, it was missing only put the # here: $('#<%= Attachment.Clientid %>') and it worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.