To check the size of a file (before form submission), you can do it easily as follows:
function validate_file(){ file_obj = document.getElementById('my_file').files[0]; if (typeof file_obj != 'undefined'){ if (file_obj.size > 2000000){ // 2Mb alert('file size is greater than 2Mb'); return false; } } return true; }
If you really want to do something fancy, check out this site:
http://www.html5rocks.com/en/tutorials/file/dndfiles/#toc-reading-files