参考一下代码,exts和acceptMime都需要设置
layui.upload.render({
elem: "#main_image",
url: "/app/admin/upload/insert",
acceptMime: "image/gif,image/jpeg,image/jpg,image/png,image/webp",
exts:'jpg|png|gif|jpeg|svg|webp',
field: "__file__",
done: function (res) {
if (res.code > 0) return layui.layer.msg(res.msg);
this.item.prev().val(res.data.url).prev().attr("src", res.data.url);
}
});
Was this helpful?
0 / 0