0

哑剧.php

        'doc'   =>  array('application/msword', 'application/vnd.ms-office'),
        'docx'  =>  array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip'),
        'dot'   =>  array('application/msword', 'application/vnd.ms-office'),
        'dotx'  =>  array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'),
        'xlsx'  =>  array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip'),
        'word'  =>  array('application/msword', 'application/octet-stream'),

var_dump 给出以下响应

string(24)"application/octet-stream"

这是我的一些控制器代码

        if(!empty($_FILES['file_name']))
                        {
                            // Profile Pic upload
                            $config = array();
                            $config['upload_path']           = 'uploads/file/'; 
                            $config['allowed_types']         = 'gif|jpg|png|jpeg|pdf|csv|txt|doc|docx|rar|zip|svg|xml|GIF|JPG|PNG|JPEG|PDF|DOC|XML|DOCX|xls|xlsx|CSV|TXT|SVG'; 
                            $config['max_size']              =10000; 
                            $config['max_width']             = 1024; 
                            $config['max_height']            = 1024; 
                            $config['file_ext_tolower']      = true;
                            $this->load->library('upload', $config, 'profilepic');
                            $this->profilepic->initialize($config);

                            if(!$profile_pic = $this->profilepic->do_upload('file_name')) 
                            {
                                $this->session->set_flashdata('message', $this->upload->display_errors());
                            }
                            else 
                            {
                                 $imgname = $this->profilepic->data();
                                 $imgpath = 'uploads/file/'.$imgname['file_name'];
                                 $data['file_name'] = $imgpath;
                            }                       
                        }else{
                            $this->session->set_flashdata('message', 

'请我尝试了所有可能的解决方案,但无法成功。请建议。

4

1 回答 1

1

我错过了控制器中的 docx,在 docx mimes 中添加“application/octet-stream”正在解决问题。感谢您的努力和时间。

于 2018-08-15T17:52:43.657 回答