Zip和rar扩展名的文件上传在Codeigniter中无效

时间:2013-04-21 05:40:34

标签: codeigniter

我正在使用codeigniter为我的博客创建文件上传功能。因为我接受两种格式zip | rar。

它提供错误不允许您尝试上传的文件类型。。它的工作正常如果 将其更改为其他格式,如图像或文本。

请找到代码段

$config['upload_path'] = './public/';
        $config['allowed_types'] = 'zip';
        $config['max_size'] = '6000';       
        //$config['file_name'] = $authorName.$config['file_ext'];
        $config['overwrite'] = TRUE;

        $this->load->library('upload', $config);



        if ( ! $this->upload->do_upload()){         
            $data['serverMessage'] = "E75";
            $data['uploadError'] = $this->upload->display_errors();
            $data['message'] =$this->upload->display_errors();

        }else{
            $data['message'] ="Thanks you";
        }

        $this->output->set_header("HTTP/1.0 200 OK");
        $this->output->set_header("HTTP/1.1 200 OK");

        $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
        $this->output->set_header("Cache-Control: post-check=0, pre-check=0");
        $this->output->set_header("Pragma: no-cache");




        $this->load->view('guestpost', $data);

3 个答案:

答案 0 :(得分:1)

添加' application / octet-stream'在config / mimes.php的zip结尾...

'zip'   =>  array('application/x-zip', 'application/zip', 'application/x-zip-compressed', 'application/s-compressed', 'multipart/x-zip', 'application/octet-stream')

答案 1 :(得分:0)

answer可能会帮助您

尝试更改MIME.php配置

答案 2 :(得分:0)

$ config ['allowed_types'] ='application / zip';

试试这个..