Skip to content
This repository was archived by the owner on Jan 29, 2021. It is now read-only.
This repository was archived by the owner on Jan 29, 2021. It is now read-only.

Validator failed to recognize file by mime #20

Description

@susilon

When I uploaded the .exe file that I renamed the extension to .pdf, validation failed to recognize the .exe file and thought the file was a .pdf file

'Uploader.FileValidation' => array(
'file' => array(
'extension' => array('pdf'),
'type' => 'application',
'mimeType' => array('application/pdf'),
'required' => true
)
),

my solution was added mime checking using finfo_open at AbstractValidator -> mimeType

public function mimeType($whitelist = array()) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $this->getFile());
return in_array($mime, (array) $whitelist);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions