title: CodeIgniter Upload image and then resize it
body: <p>I am trying to upload images and resize them, so far the upload is working and also the creation of thumb nail images. But I cant get the original image to be resized. All that is happening is the file is directly uploaded to the folder in its original size. I guess I am trying to take this image resize it then overwrite the originally uploaded file.</p>
  
  <p>Here is my code what am I missing: </p>
  
  <pre><code>//Initialise the upload file class
      $config['upload_path'] = './image_uploads/';
      $config['allowed_types'] = 'jpg|jpeg|gif|png';
      $config['max_size'] = '6048';
      $this-&gt;load-&gt;library('upload', $config);
  
      $userfile = "_upload_image";
              //check if a file is being uploaded
              if(strlen($_FILES["_upload_image"]["name"])&gt;0){
  
                  if ( !$this-&gt;upload-&gt;do_upload($userfile))//Check if upload is unsuccessful
                  {
                      $upload_errors = $this-&gt;upload-&gt;display_errors('', '');
                      $this-&gt;session-&gt;set_flashdata('errors', 'Error: '.$upload_errors);   
                      redirect('admin/view_food/'.$food-&gt;course_id);  
                  }
                  else
                  {
                      //$image_data = $this-&gt;upload-&gt;data();
  
                       ////[ THUMB IMAGE ]
                      $config2['image_library'] = 'gd2';
                      $config2['source_image'] = $this-&gt;upload-&gt;upload_path.$this-&gt;upload-&gt;file_name;
                      $config2['new_image'] = './image_uploads/thumbs';
                      $config2['maintain_ratio'] = TRUE;
                      $config2['create_thumb'] = TRUE;
                      $config2['thumb_marker'] = '_thumb';
                      $config2['width'] = 75;
                      $config2['height'] = 50;
                      $this-&gt;load-&gt;library('image_lib',$config2); 
  
                      if ( !$this-&gt;image_lib-&gt;resize()){
                  $this-&gt;session-&gt;set_flashdata('errors', $this-&gt;image_lib-&gt;display_errors('', ''));   
                }
  
                      //[ MAIN IMAGE ]
                      $config['image_library'] = 'gd2';
                      $config['source_image'] = $this-&gt;upload-&gt;upload_path.$this-&gt;upload-&gt;file_name;
                      //$config['new_image'] = './image_uploads/';
                      $config['maintain_ratio'] = TRUE;
                      $config['width'] = 250;
                      $config['height'] = 250;
                      $this-&gt;load-&gt;library('image_lib',$config); 
  
                      if ( !$this-&gt;image_lib-&gt;resize()){
                  $this-&gt;session-&gt;set_flashdata('errors', $this-&gt;image_lib-&gt;display_errors('', ''));   
                }
                 }      
             }  
  </code></pre>