我正在将个人资料图片上传到我的网站,第一次上传工作正常,但是当我尝试调整图像大小并将其重新上传到同一个文件夹时,它会中断。通过测试,我知道它正在通过数组并将数据插入数据库,但只是没有重新保存到文件夹中。
这就是我要去的一个。
$config['upload_path'] = './uploads/';
$config['file_name'] = $this->user->pen_name.'.jpg';
$config['file_path'] = './uploads/'.$this->user->pen_name.'.jpg';
$config['max-size'] = 2000;
$config['overwrite'] = TRUE;
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['remove_spaces'] = true;
$config['max_width'] = 2000;
$config['max_height'] = 3000;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload()){
$error = array('error' => $this->upload->display_errors());
}else{
$resize['source_image'] = base_url().'/uploads/'.$config['file_name'];
$resize['new_image'] = './uploads/';
$resize['file_path'] = './uploads/'.$this->user->pen_name.'.jpg';
$resize['create_thumb'] = false;
$resize['maintain_ratio'] = true;
$resize['width'] = 200;
$resize['height'] = 300;
$resize['overwrite'] = TRUE;
$this->load->library('image_lib', $resize);
$this->image_lib->resize();
$this->load->library('upload', $resize);
$this->users_model->uploadPic($resize['file_path']);
redirect($_SERVER['HTTP_REFERER']);
}
任何帮助将非常感激!