不能从formData获取参数,只能要接口地址后面传参
wx.uploadFile formData 携带参数失效let data = { "type": "jpg", "spec": "1", "bk": "blue", "beauty_degree": 1.5 } data.photo = base64Data; wx.uploadFile({ url: 'https://www.pudding233.com/api/data.php', //后端接口 filePath: tempFilePaths[0], method: 'POST', name: 'file', header: { "Content-Type": "application/json" }, // header: { 'Content-Type': 'multipart/form-data' }, formData: JSON.stringify(data), success: function (res) { wx.hideLoading({ success: (res) => {}, }); if (res.statusCode !== 200) { wx.showModal({ title: '提示', content: '上传失败', showCancel: false }); return; } else { console.log(res.data); wx.navigateTo({ url: "../imgDetail/imgDetail?img=" + res.data, events: {}, success: function (res) {} }) } }, fail(e) { wx.showModal({ title: '提示', content: '上传失败', showCancel: false }); }, complete() { wx.hideToast(); //隐藏Toast } })
2023-12-15