Welcome Guest, Not a member yet? Register   Sign In
Docx file format upload issue seems related to server configuration
#1

[eluser]fran-quero[/eluser]
Hello, I have developed a small application that allows to upload files with some formats: doc, docx, pdf, odt, rtf, txt, etc.

It works like a charm, but I made a new installation in a different server, and I get an error when I try to upload a .docx file.

As the application is exactly the same, I just can think it may be a server configuration problem, but I don't know what can I check, since the problem doesn't occur when I upload .pdf or .doc files.

The exact error I get is: The filetype you are attempting to upload is not allowed.

Here is my upload method:
Code:
private function subir_archivo()
{
  identificacion_necesaria('profesor');
  
   $config['upload_path'] = 'assets/descargas_multidiomas';
   $config['allowed_types'] = 'pdf|doc|docx|txt|rtf|odt|ppt|jpg';
   $config['max_size'] = 4096;//4MB
   $config['file_name'] = $this->security->sanitize_filename($this->input->post('archivo'));
                
        $this->load->library('upload', $config);
    
        if(!$this->upload->do_upload('archivo'))
        {
          $respuesta = array('error' => $this->upload->display_errors());
        }    
        else
        {
            $respuesta = array('upload_data' => $this->upload->data());
        }
        
        return $respuesta;
}

And here the docx line in mimes.php:
Code:
'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip'),

This same code works in the first server, but not in the new one Sad

I would appreciate any help you can give me, guys.

Thank in advance!
#2

[eluser]InsiteFX[/eluser]
Check you cpanel or whatever your hosting provider provides for you there is usally
a utility in there that allows you to define your mime types.
#3

[eluser]fran-quero[/eluser]
Thank you for your answer InsiteFX. I have added a new mime type in the cPanel:

Code:
docx => application/vnd.openxmlformats-officedocument.wordprocessingml.document

But I still get the same error: The filetype you are attempting to upload is not allowed.

I have contacted my hosting provider. I hope they can help me.

Do you think there is any other configuration I can check to make it work?

Kind regards!
#4

[eluser]InsiteFX[/eluser]
You can try these also.

Office Extension MIME Types:
./application/config/mimes.php
Code:
'.xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
'.xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'
'.potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template'
'.ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'
'.pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
'.sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide'
'.docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
'.dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'
'.xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12'
'.xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'

Register the 2007 Office system file format MIME types on servers
#5

[eluser]fran-quero[/eluser]
Thank you very much for your help, InsiteFx.

I had already tested that docx mime you gave me, without success. My hosting provider say it may be a bad programmed script :S.

We had strong words, and now they are stunding my problem.

I'll be back with news when I have them!




Theme © iAndrew 2016 - Forum software by © MyBB