uploadAvatar(e) {
let that = this
console.log(e.currentTarget.dataset.name);
let name = e.currentTarget.dataset.name
wx.chooseImage({ //微信上传接口
count: 1,
sizeType: 'compressed', //压缩图片
sourceType: ['album', 'camera'],//相册,相机
success(res)
console.log(res);
wx.uploadFile({
url: 'https://test.com/api/upload/shopTypeImg', //地址
name: 'file',//指定的文件类型
filePath: res.tempFilePaths[0],//微信回传的照片路劲
header: {//请求头
'Content-Type': 'multipart/form-data',
'Accept': 'application/json',
'accessToken': wx.getStorageSync('logs')[0].accessToken, //用户令牌
'timesta
微信小程序上传头像,使用wx.chooseImage; wx.uploadFile
最新推荐文章于 2024-05-09 15:36:07 发布
微信小程序上传头像,使用wx.chooseImage; wx.uploadFile注意使用时:我是通过点击事件触发上传头像方法
摘要由CSDN通过智能技术生成