Is there any way to check file size before uploading it using JavaScript?
I made something like that:
$('#image-file').on('change', function() { var numb = $(this)[0].files[0].size/1024/1024; numb = numb.toFixed(2); if(numb > 2){ alert('to big, maximum is 2MB. You file size is: ' + numb +' MB'); } else { alert('it okey, your file has ' + numb + 'MB') } });