CodeIgniter Image Upload - can't get error message to show

前端 未结 2 889
日久生厌
日久生厌 2021-01-28 12:41

This is my upload model

    function upload_avatar()
    {
        $id = $this->tank_auth->get_user_id();

        //config upload parameters and upload im         


        
2条回答
  •  遇见更好的自我
    2021-01-28 13:14

    $config['upload_path'] = 'uploads/category/'.$id.'/';
            //echo $file_name;die;
            //echo $config['upload_path'];
            $config['allowed_types'] = 'gif|jpg|jpeg|png';
            $config['max_size'] = '2048';
            $config['max_width'] = '1920';
            $config['max_height'] = '1280';
            $this->load->library('upload');
             foreach ($_FILES as $key => $value) {
                //print_r($key);
    
                if (!empty($key['name'])) {
    
                    $this->upload->initialize($config);
                    if (!$this->upload->do_upload($key)) {
                      // echo 'test';die;
    //                    rmdir('uploads/category/'.$id);
                        $errors = $this->upload->display_errors();
                        flashMsg($errors);
                    }
    }
    }
    

    try this!!

提交回复
热议问题