title: How can I upload a file to amazon S3 with Codeigniter/PHP?
body: <p>I'm trying to upload a file to my Amazon S3 bucket. My friend had this working on our site in the past but a year later its busted and I can't figure out what's wrong. We are using the <a href="http://www.neurofuzzy.net/2006/08/26/amazon-s3-php-class-update/" rel="nofollow">S3 PHP library</a> developed by <a href="https://twitter.com/neurofuzzy" rel="nofollow">Geoff gaudreault</a>.</p>
  
  <p>This library looks pretty straightforward to me, really it looks like there is one key function: <code>putObject()</code>. </p>
  
  <p>Unfortunately, I'm not even getting out of the gate. I'm getting the following error message:
  <code>Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.</code></p>
  
  <p>Here's my codeigniter PHP for my upload form <code>action</code>:</p>
  
  <pre><code>    function s3(){
  
      $config['upload_path'] = $_SERVER["DOCUMENT_ROOT"].'/temp/';
      $config['allowed_types'] = 'gif|jpg|png';
      $config['max_size'] = '1000000';
      $config['max_width']  = '1024000';
      $config['max_height']  = '768000';
  
      $this-&gt;load-&gt;library('upload', $config);
  
      if ( ! $this-&gt;upload-&gt;do_upload())
      {
          $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
  
          print_r($error);
          echo 'failure';
      }
      else
      {
         $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data()); 
          $fn = $data['file_name'];
          $type = substr($fn, strrpos($fn, '.') + 1);
  
      $this-&gt;load-&gt;library('s3');
      $temp_file_path = $_SERVER["DOCUMENT_ROOT"]."/temp/" . $data['file_name'];
      $contents = read_file($temp_file_path); // will this blow up or timeout for large files?! 
      $newFileName = uniqid().".".substr($temp_file_path, strrpos($temp_file_path, '.') + 1);
       $contentPath = "mysite.com/Images"; 
  
      $this-&gt;s3-&gt;putObject($newFileName, $contents, $contentPath, 'private', $type);
      echo 'success';
      }
  }
  </code></pre>
  
  <p>Does anyone have any thoughts?</p>