transit
transit copied to clipboard
Validator failed to recognize file by mime
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); }