<?php $policy = <<<EOS {"expiration": "2009-01-01T00:00:00Z", "conditions": [ {"acl": "private"}, ["starts-with", "\$key", "upload_dir/"], {"bucket": "youe-bucket"}, {"success_action_status": '201'}, ["starts-with", "\$filename", ""], ] } EOS; $signature = hash_hmac("sha1", base64_encode($policy), S3_SECRET, true); $policy = base64_encode($policy), $signature = base64_encode($signature) ?> <script