title: Posting form data to Amazon S3 bucket
body: <p>I've spent three days now trying to set up a simple posting form to amazon s3.
  Everytime I get this error:</p>
  
  <blockquote>
    <p>SignatureDoesNotMatchThe request signature we calculated does not
    match the signature you provided. Check your key and signing method.</p>
  </blockquote>
  
  <p>I don't see the problem. :-(</p>
  
  <pre><code>&lt;?php
          $form = array(
              'key'                       =&gt; 'queue/1_1_1234567890.wmv',
              'AWSAccessKeyId'            =&gt; 'mypublickeyishere',
              'acl'                       =&gt; 'public-read',
              'success_action_redirect'   =&gt; 'http://someurl.com',
          );
  
          $form['policy'] = '{
              "expiration": "2015-12-01T12:00:00.000Z",
                  "conditions": [
                      {
                          "acl": "'.$form['acl'].'"
                      },
                      {
                          "success_action_redirect": "'.$form['success_action_redirect'].'"
                      },
                      {
                          "bucket": "thenameofmybucket"
                      },
                      [
                          "starts-with",
                          "$key",
                          "queue/"
                      ]
                  ]
              }';
  
      $form['policy_encoded'] = base64_encode($form['policy']);
      $form['signature'] = base64_encode(hash_hmac( 'sha1', base64_encode(utf8_encode($form['policy'])), 'F90mc5kpjuNMPg8XG7iV6bxOzacYhktcw+RVGzpZ'));
  
  ?&gt;
  
  
  &lt;form action="https://thenameofmybucket.s3.amazonaws.com/" method="post" enctype="multipart/form-data"&gt;
        &lt;input type="hidden" name="key" value="&lt;?php echo $form['key'] ?&gt;"&gt;
        &lt;input type="hidden" name="AWSAccessKeyId" value="&lt;?php echo $form['AWSAccessKeyId'] ?&gt;"&gt;
        &lt;input type="hidden" name="acl" value="&lt;?php echo $form['acl'] ?&gt;"&gt;
        &lt;input type="hidden" name="success_action_redirect" value="&lt;?php echo $form['success_action_redirect'] ?&gt;"&gt;
        &lt;input type="hidden" name="policy" value="&lt;?php echo $form['policy_encoded'] ?&gt;"&gt;
        &lt;input type="hidden" name="signature" value="&lt;?php echo $form['signature'] ?&gt;"&gt;
  
        File to upload to S3:
        &lt;input name="file" type="file"&gt;
        &lt;br&gt;
        &lt;input type="submit" value="Upload File to S3"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I substituted the bucket name as well as the private and public keys above.</p>
  
  <p>I followed the instruction to sign the policy meticulously:
  <a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/HTTPPOSTForms.html#HTTPPOSTConstructPolicy" rel="nofollow">http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/HTTPPOSTForms.html#HTTPPOSTConstructPolicy</a></p>
  
  <p>What am I missing? Why is the code not working?</p>