160
rated 0 times
[
167]
[
7]
/ answers: 1 / hits: 32358
/ 12 Years ago, fri, february 8, 2013, 12:00:00
I'm trying to get information about the file being uploaded in an HTML input with the following code:
$(document).ready(function() {
$('#btn').on('click', function() {
file_size = $(#my_file).files[0].size;
alert(file_size);
});
});
<script src=https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js></script>
<form>
<input id=my_file type=file name=my_name />
<input id=btn type=button />
</form>
But it doesn't work, and the console returns: $(#my_file).files is undefined
More From » jquery