Hello Reader's If you are uploading the attachments with only selected file types then you have to use inarray function.
Let's see the example as below:-
Put the allowed types in an array and use in_array().
$file_type = $_FILES['foreign_character_upload']['type']; //returns the mimetype
$allowed = array("image/jpeg", "image/gif", "application/pdf");
if(!in_array($file_type, $allowed)) {
$error_message = 'Only jpg, gif, and pdf files are allowed.';
$error = 'yes';
}
Now only the files with .jpeg or gif or pdf will only upload.
0 Comment(s)