codeigniter上传类的问题

时间:2014-03-22 12:30:57

标签: php codeigniter file-upload

我在do_upload函数的上传控制器中加载上传库:

public function do_upload() {
    $upload_path_url = base_url() . 'uploads/';
    $config['upload_path'] = FCPATH . 'uploads/';
    $config['allowed_types'] = 'jpg|jpeg|png|gif';
    $config['max_size'] = '30000';

    // Here i loaded the library
    $this->load->library('upload', $config);

        // Here is the undefined $upload variable
        if (!$this->upload->do_upload()) {
        // code
        }
    // code
    }

我收到此错误:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Upload::$upload

Filename: controllers/Upload.php

Line Number: 24

Backtrace:

File: /var/www/application/controllers/Upload.php
Line: 24
Function: _exception_handler

File: /var/www/index.php
Line: 274
Function: require_once

我怎么能解决问题?

1 个答案:

答案 0 :(得分:0)

请提及您正在上传文件的输入名称,如下所示:

// Here is the undefined $upload variable
        if (!$this->upload->do_upload('input_name')) { // here you have to mention input name
        // code
        }

我认为这应该适合你。