1

I get this error when trying to upload file.

This is my code

class Upload extends CI_Controller {

    function __construct() {
        parent::__construct();

        $this->load->model(array(
                                  'm_campaign' 
                                  ,'m_upload'
                                )
                            );

        $this->load->helper(array(
                                   'form' 
                                   ,'url'
                                )
                            );

    }

    public function index()
    {
        $data = array(
                        'select_campaign'   => $this->select_campaign(),
                        'view'              => 'upload',
                        'js'                => 'script_upload'
                    );

        $this->load->view('admin/template', $data);
    }

    function select_campaign(){
        $select_campaign = $this->m_upload->table_campaign();
        return $select_campaign;
    }

    function start_upload(){

        if (!empty($_FILES)) {
            $config = array(
                                'allowed_types' => 'jpg|xls|xlsx' 
                                ,'upload_path'  =>  base_url('assets/media/excel/')
                                ,'max_size'     =>  1000000
                                ,'max_width'    =>  4024
                                ,'max_height'   =>  1768
                                ,'overwrite'    =>  true
                            );
            $this->load->library('upload', $config);

            $this->upload->do_upload();
        }
        redirect('admin/upload');
    } }
}

I've trying to search but still confuse.

Thank you for everyone here

1 Answer 1

0

It may be because your config parameter not intialize. Try this after

$this->load->library('upload', $config);
    $this->upload->initialize($config);
Sign up to request clarification or add additional context in comments.

2 Comments

Right now I get this error Fatal error: Call to undefined method Upload::initialize() do you know why ?
just remover $this->upload->initialize($config); and try again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.