0

Possible Duplicate:
Check file input size with jQuery

i need to check the uploaded image size is less than 5mb

i using the following code

$("#fileUpload").change(function () {

        $file = $("#fileUpload");
        var a = $file[0];

        var iSize = ($file[0].files[0].size / 1024);
        if (iSize / 1024 > 1) {
            iSize = (Math.round((iSize / 1024) * 100) / 100)
            alert('file size is ' + iSize);
            if (iSize > 5) {
                $('#FileImageSizeValidation').show();
            }

        }

    });

in that, i got the undefined error on $file[0].files[0]. it shows error in this line. how to do this.

thanks pooja

Community
  • 1
  • 1
Pooja
  • 495
  • 3
  • 9
  • 25

1 Answers1

0

IE 9 and lower doesn't support the HTML5 File API so you cannot obtain the file size on the client. Make sure that you are using a browser that supports this API.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928