createCameraContext

发布于 6 年前作者 wei11669 次浏览最后编辑 6 年前来自 ask

wx.createCameraContext()调用takePhoto返回的res.tempImagePath怎么转成base64的图片???

2 回复
xiulan17
xiulan171 楼6 年前

这个返回的是照片文件的临时路径,暂不支持此功能

yuanjing
yuanjing2 楼4 年前

 wx.createCameraContext().takePhoto({

    quality: ‘high’,

    success: (res) => {

      let tempImagePath = res.tempImagePath

 

      wx.getFileSystemManager().readFile({

        filePath: tempImagePath,

        encoding: ‘base64’,

        success: (res) => {

          let avatarBase64 = res.data

          console.log(avatarBase64)

          wx.hideLoading()

        }

      })

    }

  })