Closed chenjia111 closed 2 years ago
你好,在微信小程序使用这个npm包的时候遇到一个问题,上传文件只传了前面一部分
wx.chooseMessageFile({ count: 1, type: "file", extension: ["txt"], success(res) { const tempFilePaths = res.tempFiles; let filePath = tempFilePaths[0].path; let formData = new FormData(); formData.appendFile("filename", filePath, "parameter.txt"); let data = formData.getData(); wx.request({ url: "http://10.168.1.220", header: { "content-type": data.contentType }, method: "POST", data: data.buffer, }); }, });
我用你的代码本地测试是正常的,你的文件是啥样的,后台接收又是啥样的,能提供不。
不好意思,后来调试了是接口问题,发送的请求数据没问题
你好,在微信小程序使用这个npm包的时候遇到一个问题,上传文件只传了前面一部分
wx.chooseMessageFile({ count: 1, type: "file", extension: ["txt"], success(res) { const tempFilePaths = res.tempFiles; let filePath = tempFilePaths[0].path; let formData = new FormData(); formData.appendFile("filename", filePath, "parameter.txt"); let data = formData.getData(); wx.request({ url: "http://10.168.1.220", header: { "content-type": data.contentType }, method: "POST", data: data.buffer, }); }, });