0

I am trying to grab the file size, of a selected file, before a user submits the form. I am trying to use JQuery to do this so that I can prevent form submission if the file size is too big. But I can't get my code to work right.

My Jquery on form submit:

var size = $("photo-input")[0].files[0].size;

What could I be doing wrong?

  • 1
    Duplicate: http://stackoverflow.com/questions/307679/using-jquery-restricting-file-size-before-uploading – Ani Dec 17 '13 at 16:40

1 Answers1

1

You should prefix #, assuming you want to select on the basis of ID

 var size = $("#photo-input")[0].files[0].size;

HTML has no element as photo-input

Satpal
  • 132,252
  • 13
  • 159
  • 168