The accepted answer is actually correct, but you need to bind it to the event listener so that it is updated when the input file has been modified.
document.getElementById('fileInput').onchange = function(){ var filesize = document.getElementById('fileInput').files[0].size; console.log(filesize); }
If you use jQuery library, the following code may be convenient
$('#fileInput').on('change',function(){ if($(this).get(0).files.length > 0){
Given that the fileSize transformation for the display, in which the metric is always executed, is up to you.
Ammadu Jul 20 '15 at 18:53 2015-07-20 18:53
source share