[eluser]veledrom[/eluser]
Creating thumb for an image doesn't work. No error occurs. Original file exist in the folder.
Is there anything else I need to know?
1. do_add_new() get called.
2. do_upload() uploads the file
3. manipulate_image($file_name) gets called in step 2 as last process.
Thanks
Code:
public function do_add_new()
{
$this->do_upload();
if (count($this->upload_error) > 0)
{
echo '<pre>'; print_r($this->upload_error); exit;
}
echo 'DONE'; exit;
}
public function do_upload()
{
$config['upload_path'] = './application/uploads/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_size'] = 5120;
$config['max_width'] = '0';
$config['max_height'] = '0';
$config['encrypt_name'] = true;
$this->load->library('upload');
$this->upload->initialize($config);
foreach($_FILES as $file => $value)
{
if(! $this->upload->do_upload($file))
{
$this->upload_error[] = 'Failed to upload ' . $value['name'];
}
else
{
$result = $this->upload->data();
$this->manipulate_image($result['file_name']);
}
}
}
public function manipulate_image($file_name)
{
$this->load->library('image_lib');
$config['image_library'] = 'gd2';
$config['source_image'] = './application/uploads/' . $file_name;
$config['create_thumb'] = true;
$config['maintain_ratio'] = true;
$config['width'] = 50;
$config['height'] = 75;
$config['thumb_marker'] = '_thumb';
$this->load->library('image_lib', $config);
if (! $this->image_lib->resize())
{
$this->upload_error[] = 'Failed to create thumb for ' . $file_name;
}
$this->image_lib->clear();
}