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

前端 未结 2 841
日久生厌
日久生厌 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!!

    0 讨论(0)
  • 2021-01-28 13:16

    Is your post_max_size limit less than 2MB? (http://ca3.php.net/manual/en/ini.core.php#ini.post-max-size) If so the file may have been discarded before your code is invoked.

    Update:

    If you take out your function call in the else block, and just drop in an exit('too big'); are you able to see errors then? If so there may be an issue with how you're pasing the call off.

    0 讨论(0)
提交回复
热议问题