layui.use (["upload","jquery"], function () {
) var $ = layui.jquery;
var upload = layui.upload;
var srcArr = new Array();
upload.render({
elem: "-sharptest10",
url: "/uploadImgs",
multiple:true,
bindAction:"-sharpsave",
exts:"gif|jpg|jpeg|png|bmp|png",
auto:false,
size:2*1024,
choose:(obj)=>{//
var files = obj.pushFile();
obj.preview((index, file, result)=>{
$("-sharptest10").append("<div class="imgBox"><img src=""+ result +"" alt=""+ file.name +"" class="layui-upload-img remove_"+index+""></div>")
$(".remove_"+index).bind("click",function(){
delete files[index];//
$(this).parent().remove();
})
});
},done: (res)=>{
if(res.code===200){
var srcStr = res.data[0];
srcStr = srcStr.replace("public","").substring(1,srcStr.length);
srcArr.push(srcStr);
for(var i in srcArr){
$("-sharptest10 img").eq(i).attr("src",srcArr[i])
$("-sharptest10 em").eq(i).remove();
}
}
}
});-sharp-sharp-sharp
the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)