layui实现⽂件上传项⽬需求:集成bootstrap + layui + java(MultipartFile) 实现 ⽂件上传
js代码(可根据需要⾃⾏改成js或html页⾯代码):
var g = '<button type="button"class="layui-btn demoMore" title="上传⽂件"
lay-data="{url: \'/dl_manager/dlManager/uploadFile?id=' + row.id + '\',
accept: \'file\'}" >上传</button>';
layui 上传接⼝绑定
layui.use('upload', function() {
var upload = layui.upload;
//执⾏实例
layui和bootstrap哪个好var uploadInst = der({
elem: '.demoMore', //绑定元素
/
/url: '/agentkey/agentKey/uploadOpenSSl', //上传接⼝
size: 1000,
accept: 'file',
size:'204800', //kb
before: function(){
console.log('接⼝地址:'+ this.url, this.item, {tips: 1});
},
/* done: function (r) {
//layer.msg(r.msg);
de == 0){
parent.layer.msg(data.msg);
}
// Data().code;
}, */
done: function(res, index, upload){
var item = this.item;
console.log(item); //获取当前触发上传的元素,layui 2.1.0 新增
reLoad();
},
error: function(r) {
//layer.msg(r.msg);
}
});
});
layui官⽅⽂档:
java 后台⽂件上传代码:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论