1
votes

here is my file upload process

// file upload process      


$config['upload_path'] = UPLOAD_PATH ."/introduce/";
    $config['allowed_types'] = UPLOAD_ALLOW_EXT;
    $config['max_size'] = '10240';
    $config['file_name'] = time();                  
    $this->load->library('upload', $config);

    foreach($_FILES as $key => $value) 
    {
        if($_FILES[$key]['name'])
        {       
            if (!$this->upload->do_upload($key)) 
             {
                var_dump($this->upload->display_errors());
                alert('erro while file upload');
            } else {
                $upload_data = $this->upload->data();
                ${$key} = $_FILES[$key]['name'];
                ${"o".$key} = $upload_data['file_name'];
            }
        }
    }

I have same code. worked in "/controller/1.php" deosn't work in "/controller/2.php"

error massage

A PHP Error was encountered Severity: Notice Message: Undefined property: Introduce::$upload Filename: admmode/introduce.php Line Number: 77

Fatal error: Call to a member function do_upload() on a non-object in /var/www/html/application/controllers/admmode/introduce.php on line 77

2
77 line number means which line are indicate please? - Mayank Vadiya
if (!$this->upload->do_upload($key)) this line. I can't find solution.... - Serkeun Bang
also "$this->upload->do_upload('filename1');" deosn't work too. - Serkeun Bang
I already did it. point is "Undefined property: Introduce::$upload". - Serkeun Bang
Yes, I loaded upload library. - Serkeun Bang

2 Answers

1
votes

In your controller/2.php are your sure you loaded the upload library?

$this->load->library('upload')
1
votes

Go to application/config/autoload.php and add the 'upload' library like this :

$autoload['libraries'] = array('database',...,'upload');