What are better practices to prevent upload of any malicious file (with extensions like php.jpeg or even code injected without specific .php) , than declaring acceptable extensions:
$allowed = array('jpeg','png' ,'jpg','pdf');
$filename = $_FILES['any_file']['name'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if(!in_array($ext,$allowed) ) {
echo 'error';
}
and what is the problem with the following:
$filename = $_FILES['any_file']['name'];
$containsDotPhp = $filename;
if ($containsDotPhp contains '.php'){
echo 'error';
}
Or any better solution with explanation of why it is more efficient would be appreciated.