Serious answer though, I don't think the fix should be that difficult, but I don't program in PHP so don't take my word for it:
$tmp_path = /*your file here*/;
$finfo = new finfo(FILEINFO_MIME_TYPE);
$real_mime = $finfo->file($tmp_path); //get the real MIME type to know its file extension (instead of pathinfo)