Codeigniter - 致命错误

时间:2011-10-12 14:21:41

标签: php codeigniter upload

我有这个错误,Fatal error: Call to undefined method CI_Input::file() in D:\xampp\htdocs\application\controllers\page.php on line 219并使用Multiple Uploads with JQuery and Code IgniterExtended Input for Files

这是我的代码:

if($this->input->file('userfile')){ //This is line 219
    $config['upload_path'] = './uploads/'; 
    $config['allowed_types'] = 'gif|jpg|png'; 
    $config['max_size']    = '1000'; 
    $config['max_width']  = '1024';
    $config['max_height']  = '768';

    $this->upload->initialize($config);
    $this->load->library('Multi_upload');

    $files = $this->multi_upload->go_upload();
    //var_dump($files);
    if ( ! $files )
    {
        $error = $this->upload->display_errors();                           
        echo $error;
        return false;
    }
    else
    {
        $data3 = array();
        foreach ($files as $idx => $name) {
            //var_dump($name['name']);
            $data3[] = array(
                'relation' => $id_residence,
                'images' => $name['name'],
            );
        };
        $data333 = $this->db->insert_batch('hotel_image', $data3);
    }
}

1 个答案:

答案 0 :(得分:0)

而不是isset()

尝试:

$myInput = $this->input->file('userfile');
if(!empty($myInput)){
    ...
    ...
}