layui.use('upload', function () {
var $ = layui.jquery
, upload = layui.upload;
//普通图片上传
var uploadInst = upload.render({
elem: '#avatar'
,url: '{$webname}/personal/uploadimg'
,accept: 'images'
,auto: true
,before: function (obj) {
this.data = { 'id': '445' };
//预读本地文件示例,不支持ie8
obj.preview(function (index, file, result) {
$('#img').attr('src', result); //图片链接(base64)
});
}
,done: function (res) {
if (res.code == 0) {
layer.msg(res.msg);
} else {
layer.msg(res.msg);
}
}
});
})
需要传参的参数就在before在对应的参数名