我正在尝试在 codeigniter 中上传图像文件。为此,我写道:
$config['upload_path'] = '/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
if($this->load->library('upload', $config)){
echo 'Loaded !';
}else{
echo 'Unable to load';
}
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
echo 'Error';
//$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
echo 'Uploaded';
//$this->load->view('upload_success', $data);
}
但我收到了类似的错误Unable to load
Error
。当我检查我的/application/libraries
目录时,它是空的。我需要自己编写库upload
还是缺少库?我正在使用CodeIgniter 2.1.4
.