[eluser]brixxster[/eluser]
Hello again guys,
I have a code here that's suppose;
1. Save the image in "/uploads" directory.
2. If the image is saved, it will find the file to make a thumbnail version of it and save to "/uploads/thumbs" directory.
I have it running successfully in saving the image in the /uploads directory but can't seem to find the error why it is not saving the thumbnail version under /upload/thumbs directory. Please help.
The code.
Code:
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else // when file is uploaded, start making thumbnails
{
//$data = array('upload_data' => $this->upload->data());
$data = array('upload_data' => $this->upload->data());
// load image library
$this->load->library('image_lib');
// set arrays
$config2['image_library'] = 'gd';
$config2['source_image'] = '/uploads/' . $data['upload_data']['file_name'];
$config2['create_thumb'] = TRUE;
$config['new_image'] = '/uploads/thumbs/' . $data['upload_data']['file_name'];
$config2['maintain_ratio'] = TRUE;
$config2['width'] = 75;
$config2['height'] = 50;
$this->load->library('image_lib', $config2);
$this->image_lib->resize();
$this->load->view('upload_success', $data);
}
}