//只调取照相
<input type="file" id='image' accept="image/*" capture='camera' name="file" οnchange="fileup(event)" >
//调取相册(会把照相的选项也调出来)
<input type="file" name="file" οnchange="fileup(event)">
function fileup(e) {
var formData = new FormData();
formData.append('file', e.target.files[0]);
var index = layer.load(0, {shade: false}); //0代表加载的风格,支持0-2 //引用layer插件
$.ajax({
url: '/api/User/avatarUpload',
type: 'POST',
cache: false,
data: formData,
processData: false,
contentType: false
}).done(function(res) {
console.log(res.data.domain);
console.log(res.data.filepath);
$('#layui-layer-shade1,.layui-layer.layui-layer-loading').remove(); //去掉加载loading
$('#ticket2').attr('src',res.data.filepath); //给图片添加路径
}).fail(function(res) {
$('#layui-layer-shade1,#layui-layer1').remove();
});
}
https://blog.csdn.net/github_38516987/article/details/77988182 微信调取相册接口(没有用过)