[eluser]SaminOz[/eluser]
I wish to upload an image, place an untouched version in one directory and a thumb in another. I wrote something similar to the following:
Both private methods work separately - but not one after the other. Is there some obvious reason for this?
Code:
if ( ! $this->upload->do_upload())
{
$data['error'] = array('error' => $this->upload->display_errors());
}
else
{
$this->load->helper('file');
$data['error'] = $this->file_data = $this->upload->data();
$this->create_copy();
$this->create_thumb();
delete_file('path/to/file');
}
private function create_copy()
{
$config['source_image'] = $this->file_data['full_path'];
$config['new_image'] = './full_image/full_image_' .$this->identifier.$this->file_data['file_ext'];
$this->load->library('image_lib', $config);
$this->image_lib->resize();
}
private function create_thumb()
{
$config['image_library'] = 'gd2';
$config['source_image'] = $this->file_data['full_path'];
$config['new_image'] = './thumb_image/thumb_image_' .$this->identifier.$this->file_data['file_ext'];
$config['maintain_ratio'] = TRUE;
$config['width'] = 168;
$config['height'] = 101;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
}