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

Validator failed to recognize file by mime #20

Open
susilon opened this issue Aug 27, 2019 · 0 comments
Open

Validator failed to recognize file by mime #20

susilon opened this issue Aug 27, 2019 · 0 comments

Comments

@susilon
Copy link

susilon commented Aug 27, 2019

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);
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant