I'm trying to get the size of an uploaded image in JQuery. I created an event for the change of the form and inserted the following in it:
console.log($(this)[0].size);
The output of that is undefined. What am I doing wrong, and how can I get the uploaded image size?
$(document).ready(function() {
$('#uploadform').on('change', function(evt) {
console.log($(this)[0].size);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="upload.php" enctype="multipart/form-data" method="POST" id="uploadform">
<input id="openFile" name="img" type="file" />
</form>