Which of the following examples is a proper way to validate image extension?
function fileExtension($filename){
$path_info = pathinfo($filename);
return $path_info['extension'];
}
$ext=fileExtension($_FILES['filename']['name']);
$allowedExt = array("jpg","jpeg","png","bmp","gif");
if(!in_array(strtolower($tmp_exp[count($tmp_exp)-1]),$allowed_ext)){
//invalid ext
$allowedExt = array("jpg","jpeg","png","bmp","gif");
$tmp_exp = explode(".",$filename);
if(!in_array(strtolower($tmp_exp[count($tmp_exp)-1]),$allowedExt)){
//invalid ext
Using $_FILES[“uploaded_file”][“type”] for checking.