transit icon indicating copy to clipboard operation
transit copied to clipboard

Validator failed to recognize file by mime

Open susilon opened this issue 6 years ago • 0 comments

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

susilon avatar Aug 27 '19 07:08 susilon