[eluser]cip6791[/eluser]
I found this tutorial on creating multiple thumbnails when uploading an image with codeigniter but I can't get it to work.
http://codeigniter.tv/a-8/Create-multipl...thumbnails. Maybe this will be useful for others.
This is what I got:
Code:
$config['upload_path'] = './uploads/default_thumb';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_size'] = '5000';
$config['max_width'] = '5024';
$config['max_height'] = '3068';
$config['overwrite'] = TRUE;
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload()) {
$error = array('error' => $this->upload->display_errors());
}else{
$data = array(
'upload_data' => $this->upload->data(),
'imgPath' => $_FILES['userfile']['name']
);
$data1 = $this->upload->data();
$conf['image_library'] = 'imagemagick';
$conf['library_path'] = '/usr/bin/convert';
$conf['source_image'] = $data1['full_path'];
// Create an array that holds the various image sizes
$configs = array();
$configs[] = array('source_image' => $_FILES['userfile']['name'], 'new_image' => './uploads/default_thumb/120/'. $_FILES['userfile']['name'], 'width' => 120, 'height' => 120);
// Loop through the array to create thumbs
$this->load->library('image_lib');
foreach ($configs as $config) {
$this->image_lib->thumb($config, FCPATH . 'uploads/default_thumb' . $_FILES['userfile']['name']);
}
}
// redirect('home');
}
The image gets uploaded but the 120 folder is empty. I m not sure what is wrong. Source code here:
Code:
https://github.com/accent-interactive/Codeigniter.tv-video-tutorials/zipball/creating-multiple-thumbs