【发布时间】:2019-02-02 16:05:49
【问题描述】:
public function getbasicinfo()
{
if($this->form_validation->run('basicinfo')==TRUE) {
$data=$this->input->post();
$config = [
'upload_path' => 'assets/img/jobseeker',
'allowed_types' => 'gif|jpg|png',
'max_size' => '10000',
'max_width' => '1024',
'max_height' => '768',
'overwrite' => TRUE,
'encrypt_name' => FALSE,
'remove_spaces' => TRUE
];
if ( ! is_dir($config['upload_path']) ) die("THE UPLOAD DIRECTORY DOES NOT EXIST");
$this->load->library('upload', $config);
if(! $this->upload->do_upload('image'))
{
$error = $this->upload->display_errors();
$this->session->set_flashdata('image',$error);
redirect('Jobseeker_profile/editbasicinfo');
}
$img = $this->upload->data();
$data['image']=$img['file_name'].$id;
$this->load->model('jobseeker_profilemodel','profile');
$query=$this->profile->basicinfo($data);
if ($query==TRUE) {
redirect('jobseeker/jobpreference');
}
}else{
$this->load->view('jobseeker/editBasicInfoMyProfile');
}
}
使用上述方法上传图片时出现以下错误
致命错误:未捕获的错误:调用 C:\xampp\htdocs\Project\application\controllers\Jobseeker_profile.php:53 中为 null 的成员函数 do_upload() 堆栈跟踪:#0 C:\xampp\htdocs\ Project\system\core\CodeIgniter.php(360): Jobseeker_profile->getbasicinfo() #1 C:\xampp\htdocs\Project\index.php(202): require_once('C:\xampp\htdocs...' ) #2 {main} 在第 53 行的 C:\xampp\htdocs\Project\application\controllers\Jobseeker_profile.php 中抛出
【问题讨论】:
-
你在哪里定义
do_upload函数?
标签: php codeigniter-2