Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After lots of Googling, and back-and-forth on both the GitHub repository and Amazon documentation for the new PHP SDK, I’ve got a solution using Amazon’s new PHP SDK to generate the form fields, and Uploadify to actually upload the file directly to Amazon, bypassing my server. The code looks a little like this:</p> <pre><code>&lt;?php $bucket = (string) $container['config']-&gt;images-&gt;amazon-&gt;bucket; $options = array( 'acl' =&gt; CannedAcl::PUBLIC_READ, 'Content-Type' =&gt; 'audio/mpeg', 'key' =&gt; 'audio/a-test-podcast.mp3', 'success_action_redirect' =&gt; (string) $container['config']-&gt;main-&gt;base_url . 'upload/success/', 'success_action_status' =&gt; 201, 'filename' =&gt; '^' ); $postObject = new PostObject($container['amazon_s3'], $bucket, $options); $postObject-&gt;prepareData(); $formAttributes = $postObject-&gt;getFormAttributes(); $formInputs = $postObject-&gt;getFormInputs(); $uploadPath = $formAttributes['action']; ?&gt; &lt;script&gt; (function($) { $('#podcast').uploadify({ 'buttonClass': 'button', 'buttonText': 'Upload', 'formData': &lt;?php echo json_encode($formInputs); ?&gt;, 'fileObjName': 'file', 'fileTypeExts': '*.mp3', 'height': 36, 'multi': false, 'onUploadError': function(file, errorCode, errorMsg, errorString) { console.log('onUploadError', file, errorCode, errorMsg, errorString); }, 'onUploadSuccess': function(file, data, response) { console.log('onUploadSuccess', file, data, response); }, 'swf': '/assets/cms/swf/uploadify.swf', 'uploader': '&lt;?php echo $uploadPath; ?&gt;', 'width': 120 }); })(jQuery); &lt;/script&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload