docx file mime type vaidation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: docx file mime type vaidation (/showthread.php?tid=79196) |
docx file mime type vaidation - sdiri - 05-09-2021 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'); '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. RE: docx file mime type vaidation - iRedds - 05-10-2021 Windows 7, Opera, php 7.3 - works 1. You specify the mime_in rule twice. In the second case, non-mime types are specified and the field is different. 'mime_in[personal_info_blood_cert,docx,doc,jpg,JPG,jpeg,JPEG,pdf,png,epub,rtf]' 2. The mime type is determined through the FileInfo extension or, if it is not added, the type provided by the browser is used. RE: docx file mime type vaidation - InsiteFX - 05-10-2021 getClientMimeType() Returns the mime type (mime type) of the file as provided by the client. This is NOT a trusted value. For a trusted version, use getMimeType() instead: PHP Code: $type = getClientMimeType(); |