I am trying to create a cross validation of uploaded files through phpmailer using the "extension X mime" file values, the system is working to almost all files that i need to do this, but exceptionally with .rtf files the script isn't working.
The extension just disappear, the script can't get this if the file is .rtf. I'm using this script: https://stackoverflow.com/a/33349901/4623271 with some adaptations.
Bellow in the code, is the variable $ext where i can get the extension of any files allowed by the verification, except .rtf files, when the file is a .rtf, the variable becomes apparently empty.
I tried using $ext = end(explode(".", $_FILES["uploadedFile"]["name"])); but in the same way, when is a .rtf file, the variable becomes empty.
// mime verification
$finfo = new finfo(FILEINFO_MIME_TYPE);
if (false === $ext = array_search(
$finfo->file($_FILES['uploadedFile']['tmp_name']),
array(
'doc' => 'application/msword',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'rtf' => 'application/msword',
'odt' => 'application/vnd.oasis.opendocument.text',
'txt' => 'text/plain',
'pdf' => 'application/pdf',
),
true
)) {
$errorMsg .= "<br> Please, watch that the formats allowed are: \"doc\", \"docx\", \"rtf\", \"odt\", \"txt\", \"pdf\"' ";
}
For the time you spent reading this, thank you.