前端 // 加载layUi模块 layui.use([ 'element', 'layer','upload'], function () { //如果只加载一个模块,可以不填数组。如:layui.use('form') var element = layui.element; var upload = layui.upload; var layer = layui.layer; // 上传图片 C:\wamp64\www\dist\h5\backStage\HAYimgs var arrImg=[]; var uploadInst = upload.render({ elem: '#Btn', url: `http://XXXXX/h5/backStage/lib/upImg.php?imgpath=/h5/backStage/saveTR_CpunchCard2Img`, accept: 'images', field: 'file', method: 'get', acceptMime: 'image/*', multiple:true,//多文件上传 number:3,//最多上传3张 before: function (obj) { //预读本地文件示例,不支持ie8 obj.preview(function(index, file, result){ // console.log(result) var str=`<img src="${ result}" alt="">`; $('#TR_CpunchCard2ThumImg').append(str); $('#li02Btn').hide(); }); }, done: function (res) { //console.log(res),只要其中一个路径,使用 delete res.code; delete res.msg; delete res.data; delete res.thumbsrc; arrImg.push(res.imgsrc); saveStorage('TR_CpunchCard2Img',arrImg); return layer.msg(