组件使用说明:
layui.config({
base: './js/'
}).extend({
aliossUploader: 'aliossUploader'
}).use(['aliossUploader'], function() {
var aliossUploader = layui.aliossUploader;
aliossUploader.render({
elm:'#uploadMore',
fileType:'images',
multiple:true,
layerArea:['800px','500px'],
layerTitle:'上传文件到阿里云OSS',
policyUrl:'https://www.xcors.cn/pop/api/alioss/policy',
policyData:{},
policyHeader:{
Authorization:layui.data('XCORS').Authorization
},
codeFiled:'code',
codeStatus:0,
policyMethod:'GET',
accessidFiled : 'accessid',
policyFiled : 'policy',
signatureFiled : 'signature',
httpStr:'https',
region:'oss-cn-shanghai',
bucket: 'xcors',
prefixPath:'coordtrans/',
allUploaded:function(res){
layer.msg(JSON.stringify(res));
},
policyFailed:function(res){
layer.msg(JSON.stringify(res));
},
uploadRenderData:{
size:100
}
});
});
效果图:
需要注意:
1.签名需要请求后端
2.阿里OSS要设置POST跨域, 不然浏览器上传文件不会成功
更多详细内容参见我的个人博客 :
https://blog.coder666.cn/2019/04/10/blog27/
已知发现的BUG,已于2019-04-12晚上修复,请大家放心使用.