I've been trying to upload and resize an image. The upload seems to be finally be working, but it's not resizing.
In my constructor I am loading the library
$this->load->library('image_lib');
and then in my function I'm calling the the resize and upload
$this->require_auth();
$img = $this->input->post('photo1');
$config['upload_path'] = './HTML/files/';
$config['file_name'] = 'photo1.jpg';
$config['file_path'] = './HTML/files/photo1.jpg';
$config['max-size'] = 2000;
$config['image_library'] = 'gd2';
$config['source_image'] = $config['file_path'];
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = FALSE;
$config['width'] = 549;
$config['height'] = 549;
$config['overwrite'] = TRUE;
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['new_image'] = $config['file_path'];
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('photo1')){
$error = array('error' => $this->upload->display_errors());
var_dump($error);
}else{
$this->blog_model->editServiceImg1($config['file_path']);
redirect('/blog');
}
I have also tried this
$this->require_auth();
$img = $this->input->post('service_photo1');
$config['upload_path'] = './HTML/files/';
$config['file_name'] = 'service_photo1.jpg';
$config['file_path'] = './HTML/files/service_photo1.jpg';
$config['max-size'] = 2000;
$config['overwrite'] = TRUE;
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('service_photo1')){
$error = array('error' => $this->upload->display_errors());
var_dump($error);
}else{
$config['image_library'] = 'gd2';
$config['source_image'] = $config['file_path'];
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = FALSE;
$config['width'] = 549;
$config['height'] = 549;
$config['new_image'] = $config['file_path'];
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->blog_model->editServiceImg1($config['file_path']);
redirect('/blog');
}
Is there something I'm missing? I've tried doing the resize after the initial upload as well and that seemed to do nothing as well. Any help would be much appreciated.