I am creating a script which allows the user to upload images but now I want to include a simple if statement which will accept only gif and png . Here is my code but it doesn’t seem to be working the way it has to .
#extention filter
$allowed = array("image/gif","image/png");
if(!in_array($files,$allowed)){
$error_message = 'Only jpg, gif, and pdf files are allowed.';
$error = 'yes';
echo $error_message;
exit();
} #extention
1 Answer