0

When trying to check the MIME file type it's not working. it's taking all files to restricted error. if game.exe is renamed as game.docx and uploaded then it need to be blocked. here am attaching the code. kindly anyone checks and please help me to solve the issue.


function cf7_custom_file_validation ($result, $tag) {
    if ($tag->name === 'file-234') {
        $contentType = mime_content_type($_FILES[$tag->name]['tmp_name']);
        if ($contentType !== 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' || $contentType !== 'application/pdf' || $contentType !== 'application/msword') {
            $result->invalidate($tag, 'This file type is not supported');
        }
    }

    return $result;
}

1 Answers1

0

You have to use && instead of ||

Now, for example, a pdf is different of word so will enter the if.