Home >>Advance PHP Tutorial >Check image extension before uploading
<?php $supported_image = array('gif','jpg','jpeg','png'); $src_file_name = 'abskwlfd.png'; $ext = strtolower(pathinfo($src_file_name, PATHINFO_EXTENSION)); //echo $ext; // Using strtolower to overcome case sensitive if (in_array($ext, $supported_image)) { echo "it's image"; } else { echo 'not image'; } ?>