$("#my_file")is a jQuery object, and the jQuery object has no property files...
To get the DOM element from jQuery do
($("#my_file"))[0].files[0].size
As an additional note, if you did not select any file, ($("#my_file"))[0].files[0]it gives you undefinedand ($("#my_file"))[0].files[0].sizewill cause an error.
You are advised to add a check ...
if (($("#my_file"))[0].files.length > 0) {
file_size = ($("#my_file"))[0].files[0].size
} else {
}
source
share