//上传本地图片
uploadImg: function (e) {
var that = this
wx.chooseImage({
count: 1,
sizeType: ['compressed', 'original'],
sourceType: ['album', 'camera'],
success(res) {
var tempFilePaths = res.tempFilePaths
for (var i = 0; i < tempFilePaths.length; i++) {
wx.uploadFile({
filePath: tempFilePaths[i],
url: 接口地址,
name: 'file',
header: {
'Content-Type': 'multipart/form-data',
'token': getApp().globalData.token
},
success: function (res) {
that.setData({
})
}
})
}
}
})
}
微信小程序 上传本地图片
于 2022-05-23 10:02:52 首次发布