Hello,
I'm facing a problem with mime type validation of a docx file uploaded,
the mime :
application/vnd.openxmlformats-officedocument.wordprocessingml.document
It's work fine only with PDF and plan text:
Also a problem with the method :
PHP Code:
$file->getClientMimeType();
I'm not able te see echo out the mime type of JPG, JPEG, DOX, DOC it's work only with PDF and txt file why?
This is how i use the validation :
PHP Code:
$file = $this->request->getFile('info_cert');
/*
echo '<br> <b>MIME TYPE</b><br>';
echo $file->getClientMimeType();
echo '<br> <b> / MIME TYPE</b><br>';*/
$docx = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; // I use it as variable just to see i get something but no results also..
$validated = $this->validate([
'info_cert' => [
'uploaded[info_cert]',
"mime_in[info_cert,image/png,image/jpeg,image/gif,image/png,application/pdf,${docx},application/msword,application/vnd.oasis.opendocument.text,application/epub+zip,application/octet-stream]",
'max_size[info_cert,15360]','mime_in[personal_info_blood_cert,docx,doc,jpg,JPG,jpeg,JPEG,pdf,png,epub,rtf]'
],
]);
if ($validated)
{
echo $file->getPath();
dd($file);
//if ($pdf_blob = fopen($file_tmp, "rb")) {}
if($oldRecord && 0 < $this->request->getPost('user_id') &&
$oldRecord == $this->request->getPost('user_id') && !empty($personalInfo)){
$qbuilder_personalInfo->where('user_id',$oldRecord );
$qbuilder_personalInfo->update($personalInfo);
return $this->redirectToUserProfile();
}else{
$personalInfo['user_id'] = trim($this->sanitizePostStr($this->request->getPost('user_id')));
$qbuilder_personalInfo->insert($personalInfo);
return $this->redirectToUserProfile();
}
}else{
echo '<br>not valid<br>';
}
I don't know maybe the dot not accepted I tried with a backslash like this (
vnd\.openxmlformats) but not worked.