Welcome Guest, Not a member yet? Register   Sign In
docx file mime type vaidation


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:

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.. 
[font=Input, monospace, Consolas,]$validated = $this->validate([
                        'info_cert' => [
                    if ($validated)
                        echo $file->getPath();
                        //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 );

                        return $this->redirectToUserProfile();
                            $personalInfo['user_id'= trim($this->sanitizePostStr($this->request->getPost('user_id')));
                            return $this->redirectToUserProfile();
                        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.

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.

2. The mime type is determined through the FileInfo extension or, if it is not added, the type provided by the browser is used.


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(); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Theme © iAndrew 2016 - Forum software by © MyBB