Is there any way to check file size before uploading it using JavaScript?
Works for Dynamic and Static File Element
Javascript Only Solution
function ValidateSize(file) { var FileSize = file.files[0].size / 1024 / 1024; // in MB if (FileSize > 2) { alert('File size exceeds 2 MB'); // $(file).val(''); //for clearing with Jquery } else { } }