配置:exts即可,以|分割,设置多个文件后缀。
layui.use('upload', function(){
var upload = layui.upload;
var uploadInst = upload.render({
elem: '#downfile' //绑定元素
,url: "{:url('vip/news/upload')}" //上传接口
,exts: 'xls|xlsx|csv|zip|pdf|doc|docx|png|jpeg|jpg|gif'// 设置允许上传的格式
,field: 'downfile'
,auto:false // 是否自动上传,这里是否
,choose: function(obj){
var files = obj.pushFile();
obj.preview(function(index, file, result){
// console.log(index,file,result);
$("#fileinput").val(file.name);
});
}
});
});