我上传图片时数组到字符串的转换

时间:2019-06-15 17:11:15

标签: php codeigniter

我正在尝试过去两天,当我上传图片时一次又一次遇到相同的错误

public function add_theme(){
        $config = [
            'upload_path' => './uploads/',
            'allowed_types' => 'jpg|gif|png',
        ];

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

        if($this->form_validation->run('add_theme') && $this->upload->do_upload()){


            $data = $this->upload->data();
            echo '<pre>';
            print_r($data);
            exit;

        }else{
            $error = array('error' => $this->upload->display_errors());
            echo $error;//$this->create_template();
        }
}

1 个答案:

答案 0 :(得分:0)

可以使用

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