codeigniter未定义属性:Introduce :: $ upload error

时间:2016-03-11 09:22:50

标签: php codeigniter

这是我的文件上传过程

// 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'];
            }
        }
    }

我有相同的代码。 曾在" /controller/1.php " deosn在" /controller/2.php "

错误按摩

  

遇到PHP错误严重性:通知消息:未定义   property:Introduce :: $ upload文件名:admmode / introduction.php Line   数量:77

     

致命错误:在非对象中调用成员函数do_upload()   第77行的/var/www/html/application/controllers/admmode/introduce.php

2 个答案:

答案 0 :(得分:1)

在你的控制器/ 2.php中你确定加载了上传库吗?

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

答案 1 :(得分:0)

转到application / config / autoload.php并添加“ upload”库,如下所示:

  

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