I have been able to validate file uploads and only jpg & gif files can be uploaded.
with code like this:
<script>
function validate() {
var filename=document.getElementById('file').value;
var extension=filename.substr(filename.lastIndexOf('.')+1).toLowerCase();
//alert(extension);
if(extension=='jpg' || extension=='gif') {
return true;
} else {
alert('Not Allowed Extension!');
return false;
}
}
</script>
if I upload a file with the name "tesFile.php.jpg" the file is uploaded successfully. Even though the file is not an image.
How do I validate it with javascript or PHP ?