Welcome Guest, Not a member yet? Register   Sign In
Image resize before upload
#1

[eluser]davehedgehog[/eluser]
Hey, uh wonder if anyone could help? Im trying to upload an image and then create a smaller image and a thumb and store them in separete folders. As it stands the main image uploads but the smaller onse dont, shouldnt the image resize store the images to the new path?

Here is my do_upload in the controller~

Code:
public function do_upload()
{
  $this->load->library('image_lib');

  $config['upload_path'] = './uploads/blog/';
  $config['allowed_types'] = 'gif|jpg|png';
  $config['max_size'] = '4442048';
  $config['max_width']  = '1024';
  $config['max_height']  = '768';

  $this->load->library('upload', $config);

  if ( ! $this->upload->do_upload())
  {
   $this->form_validation->set_message('do_upload', $this->upload->display_errors(), 'Dodgy Blog entry :/');
   return FALSE;
  }
  else
  {
   $data = array('upload_data' => $this->upload->data());
  
   $config['image_library'] = 'gd2';
   $config['source_image'] = $data['Image'];
   $config['new_image'] = './uploads/blog/last/';
   $config['create_thumb'] = 'TRUE';
   $config['maintain_ratio'] = 'TRUE';
   $config['width'] = '400';
   $config['height']  = '300';

   $this->load->initialize($config);
   $this->image_lib->resize();  

   $config['image_library'] = 'gd2';
   $config['source_image'] = $data['Image'];
   $config['new_image'] = './uploads/blog/thumb/';
   $config['create_thumb'] = 'TRUE';
   $config['maintain_ratio'] = 'TRUE';
   $config['width'] = '36';
   $config['height']  = '36';

   $this->load->initialize($config);
   $this->image_lib->resize();
  
   if ( ! $this->image_lib->resize())
   {
    echo $this->image_lib->display_errors();
    $this->session->set_flashdata('flashError', 'No smaller images stored :/');
   }
  }
}


Messages In This Thread
Image resize before upload - by El Forum - 04-03-2013, 02:53 PM
Image resize before upload - by El Forum - 04-03-2013, 10:15 PM
Image resize before upload - by El Forum - 04-03-2013, 11:52 PM
Image resize before upload - by El Forum - 04-04-2013, 12:59 AM
Image resize before upload - by El Forum - 04-05-2013, 06:11 AM
Image resize before upload - by El Forum - 04-05-2013, 09:14 PM
Image resize before upload - by El Forum - 04-07-2013, 12:21 PM
Image resize before upload - by El Forum - 04-09-2013, 09:13 PM
Image resize before upload - by El Forum - 04-10-2013, 02:42 AM
Image resize before upload - by El Forum - 05-05-2013, 11:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB