uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['camera','album'], //这要注意,camera掉拍照,album是打开手机相册
success: (chooseImageRes) => {
const tempFilePaths = chooseImageRes.tempFilePaths;
uni.uploadFile({
url: 'https://www.example.com/upload', //仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
name: 'file',
formData: {
'user': 'test'
},
success: (uploadFileRes) => {
console.log(uploadFileRes.data);
}
});
}
});
});