Wednesday, April 3, 2013

Validating Upload File Size And Type on Client Side

//Validating Upload File Size And Type on Client Side
<script type="text/javascript">
    function onSelect(e) {
        // Array with information about the uploaded files
        var files = e.files;
 
        if (files[0].size > 1048576) {
            alert("File Size Can't be more than 1MB");
            e.preventDefault();
        }
        if (files[0].extension != ".jpg") {
            alert("Just Pictures Files Are Allowed");
            e.preventDefault();
        }
    }
</script>

No comments:

Post a Comment