title: upload multiple files to amazon s3 fails
body: <p>I am using codeingiter with s3 library, everything works fine with single file uploads, but when I try to upload multiple photos and their thumbnails, it hangs at the second putObject (the first thumbnail of the first file)</p>
  
  <p>the code is this:</p>
  
  <pre><code>function photosAddAction()
  {
      $files = array();
      $files_data = $_FILES["uploads"];
  
      if (is_array($files_data["name"])) 
      {
          //This is the problem
          for ($i = 0; $i &lt; count($files_data['name']); ++$i) 
          {
              $files[] = array(
                           'name' =&gt; $files_data['name'][$i],
                           'tmp_name' =&gt; $files_data['tmp_name'][$i],
                         );
          }
       }
       else 
       {
           $files[] = $files_data;
       }
  
       foreach ($files as $file) 
       {       
          //prepare data
          $chars = '0123456789abcdefghijklmnopqrstuvwxyz';
          $rand = substr(str_shuffle($chars), 0, 6);
  
          //prepare file info
          $file['tempDir'] =  sys_get_temp_dir();
          $file['targetFile'] =   $this-&gt;uri-&gt;segment(2).'_'.time().'_'.$rand;
          $file['extension'] =    pathinfo($file['name'], PATHINFO_EXTENSION);
  
          //upload original
          $this-&gt;load-&gt;library('s3');
          $this-&gt;s3-&gt;putObject($this-&gt;s3-&gt;inputFile($file['tmp_name'], false), 'mybucket', 'images/'.$file['targetFile'].'.'.$file['extension'], S3::ACL_PUBLIC_READ);
  
          //create and upload thumbnails
          $this-&gt;create_thumbnail(array('width' =&gt; 800, 'height' =&gt; 800, 'file' =&gt; $file));
          $this-&gt;create_thumbnail(array('width' =&gt; 100, 'height' =&gt; 100, 'file' =&gt; $file));   
       }
  
  function create_thumbnail($data)
  {
      log_message('info', 'create thumb called');
      $new_image ='t'.$data['width'].'x'.$data['height'].'_'.$data['file']['targetFile'].'.'.$data['file']['extension'];
  
      //resize config
      $config['image_library'] = 'gd2';
      $config['source_image']= $data['file']['tmp_name'];
      $config['create_thumb'] = FALSE;
      $config['maintain_ratio'] = TRUE;
      $config['width'] = $data['width'];
      $config['height'] = $data['height'];
  
      //resize image
      $this-&gt;load-&gt;library('image_lib'); 
      log_message('info', 'image_lib');
      $this-&gt;image_lib-&gt;initialize($config);
      $this-&gt;image_lib-&gt;resize();
      $this-&gt;load-&gt;library('s3');
  
      //upload image
      log_message('info', 'put');
      $putCommand = $this-&gt;s3-&gt;putObject($this-&gt;s3-&gt;inputFile($config['source_image'], false), 'mybucket', 'images/'.$new_image, S3::ACL_PUBLIC_READ);
  
      if($putCommand)
      {
          log_message('info', $data['width'].'x'.$data['height'].' uploaded');
          log_message('info', $putCommand-&gt;getRequest()-&gt;getUrl());
      }
      else
      {
          log_message('error', $data['width'].'x'.$data['height'].' upload FAILED');
      }
  
      log_message('info', 'put done');
      $this-&gt;image_lib-&gt;clear();             
  }
  </code></pre>
  
  <p>the last log entries are:</p>
  
  <pre><code>DEBUG - 2013-06-12 20:10:33 --&gt; Model Class Initialized
  DEBUG - 2013-06-12 20:10:33 --&gt; Controller Class Initialized
  DEBUG - 2013-06-12 20:10:33 --&gt; Image Lib Class Initialized
  INFO  - 2013-06-12 20:10:40 --&gt; create thumb called
  INFO  - 2013-06-12 20:10:40 --&gt; image_lib
  INFO  - 2013-06-12 20:10:41 --&gt; put
  </code></pre>
  
  <p>can anyone direct me in the right direction?</p>
  
  <p>thanks</p>