title: Amazon s3 upload fail
body: <p>I have been working on some code to submit an uploaded image to PHP from C# and then storing the image on Amazon S3, I have got as far as I have wanted uploading it to localhost, but I'm just unable to upload it to Amazon S3. Just wondering if you guys can give me a little help? No worries if your not willing to.</p>
  
  <p>I'm using an amazon s3 PHP class found <a href="http://undesigned.org.za/2007/10/22/amazon-s3-php-class" rel="nofollow">here</a></p>
  
  <p>Here's my code.</p>
  
  <pre><code>&lt;?php
  
  if (!class_exists('S3'))require_once('S3.php');
  if (!defined('awsAccessKey')) define('awsAccessKey', 'CHANGEME');
  if (!defined('awsSecretKey')) define('awsSecretKey', 'CHANGEME');
  $s3 = new S3(awsAccessKey, awsSecretKey);
  
  
  
  
  
  $uploaddir = 'upload/'; // Relative Upload Location of data file
  $random_digit=rand(0000,9999); // random 4 digit to add to our file name 
  $nextWeek = time() + (7 * 24 * 60 * 60); //Gets system time.
  $counter = 1;
  if (is_uploaded_file($_FILES['file']['tmp_name']))
  {
      if(strpos(basename($_FILES['file']['name']), ".")){
      $s1 = explode(".", basename($_FILES['file']['name']));
      $p1 = count($s1) - 2;
      $p2 = count($s1) - 1;
  
      $uploadfile = $uploaddir . $s1[$p1] . $random_digit . $nextWeek  . "." .    $s1[$p2];
      $s3-&gt;putObjectFile($uploadfile, "bucketname", $uploadfile, S3::ACL_PUBLIC_READ);
  } 
  else 
      {
      $uploadfile = $uploaddir . basename($_FILES['file']['name']) .  $random_digit . $nextWeek ;
      $s3-&gt;putObjectFile($uploadfile, "bucketname", $uploadfile, S3::ACL_PUBLIC_READ);
      }
  if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile))
  {
      $url = explode("/", $uploadfile);
      echo $url[1];
  }
  else
      {
          print_r($_FILES);
      }
  
  }
  
  else {
  
  echo "Upload Failed!!!";
  
  print_r($_FILES);
  }
  
  ?&gt;
  </code></pre>
  
  <p>The two lines of code have been added under the working upload lines starting with <code>$uploadfile</code></p>