//选取图片
wx.chooseImage({
count: 1,
sizeType: ['original'],//原图
sourceType: [ 'album','camera'],//支持选取图片
success (res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths[0];
//上传图片
wx.uploadFile({
//请求后台的路径
url: 'http://192.168.35.201:8090/image',
//小程序本地的路径
filePath: tempFilePaths,
//后台获取我们图片的key
name: 'images',
//额外的参数formData
formData: {
'id': 'test',
a:{ abc:'111'},
b:[1,2,3]
},
success: function (res) {
//上传成功
debugger
},
fail: function (res) {
debugger
},
})
}
})