收藏
回答

为什么模拟器能上传图片,真机上传就一直在上传中?

同一张图片

回答关注问题邀请回答
收藏

2 个回答

  • 文宠哲
    文宠哲
    2020-04-21

      var that = this;

        wx.chooseImage({

          count: 1,

          success: function (res) {

            wx.showLoading({

              title: '上传中',

            })

            const filePath = res.tempFilePaths[0]

            const tempFile = filePath.split('.')

            // 上传图片

            const cloudPath = 'my-image' + tempFile[tempFile.length - 2]

            wx.cloud.uploadFile({

              cloudPath,

              filePath,

              success: res => {

                that.setData({

                  filePath: res.fileID

                })

                wx.hideLoading()

              }

            })

          },

        })


    2020-04-21
    有用
    回复
  • Mr.Zhao
    Mr.Zhao
    2020-04-21


    打印下fail
    wx.cloud.uploadFile({
      cloudPath,
      filePath,
      successres => {
       that.setData({
         filePath: res.fileID
       })
       wx.hideLoading()
      },
      failres => {
       console.error(res)
      }
    })
    
    2020-04-21
    有用
    回复 7
    • 文宠哲
      文宠哲
      2020-04-21
      一直显示在上传中,打印不出来
      2020-04-21
      回复
    • Mr.Zhao
      Mr.Zhao
      2020-04-21回复文宠哲
      猜不出来啊,控制台截图有吗
      2020-04-21
      回复
    • 文宠哲
      文宠哲
      2020-04-21
      打印出来了
      Error: errCode: -501007 invalid parameters | errMsg: cloud path is invalid
          at new u (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:233948)
          at Function.success (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:285919)
          at Object.eval [as success] (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:127441)
          at y (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:538311)
          at v (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:538549)
          at eval (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:540103)
          at Object.v (eval at n.call.document (runtime.js?devtools_ignore=true:1), <anonymous>:2:77034)
          at u (runtime.js?devtools_ignore=true:1)
          at w (runtime.js?devtools_ignore=true:1)
          at WebSocket.ke.onmessage (runtime.js?devtools_ignore=true:1)
      2020-04-21
      回复
    • Mr.Zhao
      Mr.Zhao
      2020-04-21回复文宠哲
      打印下 cloudPath 看看是什么,学会排查问题
      2020-04-21
      回复
    • 文宠哲
      文宠哲
      2020-04-21
      my-imagewxfile://tmp_0dcbbca1e7b05f3dd601aac1493b494a559b1bc390c28a15
      2020-04-21
      回复
    查看更多(2)
登录 后发表内容
问题标签