月光寺冰 2021-05-19 20:46 采纳率: 100%
浏览 111
已采纳

微信小程序上传百度AI上识别图片编码base64失败是怎么回事啊?

百度AI要图片为base64编码的,我用filesystemmanager.ReadFile总是返回的是fail
也不报错
使用的是微信开发者工具,JS后台

wx.chooseImage({
      
      sizeType: ['original', 'compressed'],
      sourceType: [type],
      success: function (res) {
      
        var tempFilePaths = res.tempFilePaths
        that.tempFilePath = tempFilePaths
        //console.log(tempFilePaths)
        //that.getkey(res.data)
        wx.getFileSystemManager().readFile({
          
          filePath:tempFilePaths,
          encoding:'base64',
          //decoding:"base64",
          success:res=>{
            console.log(res.data)
            //that.getkey(res.data)
           
          },
          fail:res=>{
            console.log('fail')
            wx.hideLoading();
            wx.showToast({
              title: '拍照失败',
              icon: "none"
            })
            

          }
        
        })


 

  • 写回答

3条回答 默认 最新

  • CSDN专家-林老师 2021-05-19 20:52
    关注

     

     

    wx.chooseImage(Object object)的success回调返回的tempFilePaths是一个数组哦。。。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?