试试将参数放在header里
uni.uploadFile({
url: ‘https://abc.com’,
filePath: tempFilePath,
name: ‘file’,
header: {
‘Token’: that.user.token,
‘Type’: that.selectitem
},
success: (uploadFileRes) => {
}
});
wx.uploadFile formData后台获取不到内容?
试试将参数放在header里
uni.uploadFile({
url: ‘https://abc.com’,
filePath: tempFilePath,
name: ‘file’,
header: {
‘Token’: that.user.token,
‘Type’: that.selectitem
},
success: (uploadFileRes) => {
}
});
1 个评论
您还可以检查您从前端收到的错误。另一个需要注意的重要事项是,您的后端应该接收Multipart/formdata。
uni.uploadFile({ url: ‘https://abc.com’, filePath: tempFilePath, name: ‘file’, header: { ‘Token’: that.user.token, ‘Type’: that.selectitem }, success: (uploadFileRes) => { // ... }, fail : (err) => { // ...注意这里的错误 }