wx.chooseImage({ success: function (res) { var tempFilePath = res.tempFilePaths[0]; const ctx = wx.createCanvasContext('myCanvas') ctx.drawImage(tempFilePath, 0, 0, 300, 150) ctx.draw(); wx.canvasToTempFilePath({ x: 100, y: 200, destWidth: 300, destHeight: 150, canvasId: 'myCanvas', success: function (res) { var url = "http://127.0.0.1:3000/"; var uploadTask = self.uploadPhoto(url, res.tempFilePath); uploadTask.onProgressUpdate((res) => { console.log('上传进度', res.progress) console.log('已经上传的数据长度', res.totalBytesSent) console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend) }) } })
从相册中选择图片后绘制到canvas中,再由canvasToTempFilePath生成图片上传到服务器,为何生产的图片是空的
我也遇到了同样的问题,解决了吗