代码如下:
public function do_upload(){
下列地址 有两个可以用的
// $config['upload_path']='http://localhost/CITest/static/uploads/'; 不可行
$config['upload_path']=getcwd().'/static/uploads/';//可行
如果还是提示 文件路径不匹配的话
查看config配置或者auto_load.php
auto_load.php 配置不能再有upload,如图
$config['max_size']=2048000;
$config['max_width']=1024;
$config['max_height']=1024;
$this->load->library('upload',$config);
if(!$this->upload->do_upload('userfile')){
$error=array('error'=>$this->upload->display_errors());
$this->load->view('templates/header.php');
$this->load->view('file/upload_form.php',$error);
$this->load->view('templates/footer.php');
}else{
$data=array('upload_data'=>$this->upload->data());
$this->load->view('templates/header.php');
$this->load->view('file/upload_success',$data);
$this->load->view('templates/header.php');
}
}