title: Codeigniter Multiple file upload and thumbnail creation: only one thumbnail being uploaded
body: <p>I am able to upload my images ok, I am able to create thumbnails ok, but only the first thumbnail is being uploaded. I checked the error code for the resize function and they all say 'true' (Success). However, if I upload 4 files, only the first is being uploaded to the thumbnail folder. Here is my code:</p>
  
  <pre><code>function _upload_them_images($_FILES, $last_insert_id)
  {
      $error = '';
      // for($i=0; $i&lt;count($_FILES); $i++)
      for($i=0; $i&lt;count($_FILES['imagefile']['name']); $i++)
      {
  
          $_FILES['userfile']['name']         = $_FILES['imagefile']['name'][$i];
          $_FILES['userfile']['type']         = $_FILES['imagefile']['type'][$i];
          $_FILES['userfile']['tmp_name']     = $_FILES['imagefile']['tmp_name'][$i];
          $_FILES['userfile']['error']    = $_FILES['imagefile']['error'][$i];
          $_FILES['userfile']['size']     = $_FILES['imagefile']['size'][$i];
  
          $config['file_name']     = $last_insert_id.'_'.time().rand(1000,9999).$i;
          $config['upload_path']   = './images/vehicles/';
          $config['allowed_types'] = 'jpg|jpeg|gif|png';
          $config['max_size']      = '1000';
          $config['overwrite']     = FALSE;
  
          $this-&gt;upload-&gt;initialize($config);
  
          if($this-&gt;upload-&gt;do_upload())
          {
              $upload_result = $this-&gt;upload-&gt;data();             
              $rc = $this-&gt;_image_name_into_database(
                  $last_insert_id,
                  $upload_result['file_name']);               
              $image_config = array(
                  'source_image'      =&gt;$upload_result['full_path'],
                  'new_image'             =&gt; './images/vehicles/thumbs/', 
                  'create_thumb'      =&gt; TRUE,
                  'maintain_ratio'    =&gt; TRUE,
                  'width'                     =&gt; 75, 
                  'height'                    =&gt; 50
              );
  
              $this-&gt;load-&gt;library('image_lib', $image_config);
              $resize_rc = $this-&gt;image_lib-&gt;resize();            
              $error += 0;            
          }
          else
          {    
              //if the image was not uploaded successfully, try resizing  
              $error += 1;
          }
      }
      if($error &gt; 0)
      { 
          return FALSE; 
      }
      else
      { 
          return TRUE; 
      }     
  }  
  </code></pre>