1
votes

I have a problem with the xls and xlsx mimes types. I'm trying to upload an excel file but I get string(130)

"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet"

but i have that type in mi xlsx mime

'xlsx'  =>  array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip'),

This is my upload controller

public function agregararchivo() {
    if ($_FILES["userfile"]['name']=='') {
        // Here you can directly redirect to the form page itself with the Error Message
    } else {
        $new_name = time().$_FILES["userfile"]['name']; //This line will be generating random name  
        $config['upload_path'] = FCPATH ."assets/imagenusuario/";
        $config['allowed_types'] = 'xlsx|xls';
        $config['file_name'] = $new_name;            
        $this->load->library('upload', $config); //Loads the Uploader Library
        $this->upload->initialize($config);        
        if (!$this->upload->do_upload('userfile'))  {}
        else { 
            $data = $this->upload->data();
        }
    }
}

I don't know what is wrong, if I have that type in the mimes it should work but it doesn't.

1

1 Answers

0
votes

Just had the same problem with mime_content_type()

It's a PHP bug, you can see it here: https://bugs.php.net/bug.php?id=77784