var policyText = { "expiration": "2023-01-01T12:00:00.000Z", //设置该Policy的失效时间,超过这个失效时间之后,就没有办法通过这个policy上传文件了 "conditions": [ ["content-length-range", 0, 1048576000] // 设置上传文件的大小限制 ] }; accessid = 'LTAI4G4vE6yQ8YRztNZ65Wrf'; accesskey = 'OCyBu0ThZOgSHz2JLHyXOm7evWf0NA'; host = 'https://ytyss.oss-cn-beijing.aliyuncs.com'; dirname = 'abc/'; var policyBase64 = Base64.encode(JSON.stringify(policyText)) message = policyBase64 var bytes = Crypto.HMAC(Crypto.SHA1, message, accesskey, { asBytes: true }); var signature = Crypto.util.bytesToBase64(bytes); var uploader = new plupload.Uploader({ runtimes: 'html5,flash,silverlight,html4', browse_button: 'selectfiles', //runtimes : 'flash', container: document.getElementById('container'), flash_swf_url: 'lib/plupload-2.1.2/js/Moxie.swf', silverlight_xap_url: 'lib/plupload-2.1.2/js/Moxie.xap', url: host, multipart_params: { 'Filename': '${filename}', 'key': dirname + '${filename}', 'policy': policyBase64, 'OSSAccessKeyId': accessid, 'success_action_status': '200', //让服务端返回200,不然,默认会返回204 'signature': signature, }, init: { PostInit: function() { document.getElementById('ossfile').innerHTML = ''; document.getElementById('postfiles').onclick = function() { uploader.start(); return false; }; }, FilesAdded: function(up, files) { plupload.each(files, function(file) { document.getElementById('ossfile').innerHTML += '