收藏
回答

uploadFile上传文件失败,但是使用web端可以正常上传?

buttonHandler() {

    var that = this

    wx.chooseImage({

        count: 1,

        sizeType: ['original', 'compressed'],

        sourceType: ['album', 'camera'],

        success: function(res) {

            console.log(res)

            var tempFilePaths = res.tempFilePaths

            // that.setData({

            //   image_src: tempFilePaths

            // })

            that.tempFilePath = tempFilePaths

            wx.uploadFile({

              complete(res){

                console.log(res)

              },

                url: 'http://127.0.0.1:5000/test',

                filePath: tempFilePaths[0],

                name: 'test',

                fail: function(res){

                  wx.showToast({

                    title: '失败',

                    duration: 1000

                  })

                },

                success: function (res) {

                    console.log(res)

                    var datas = JSON.parse(res.data.replace(/'/g, '"'))

                    console.log(datas)

                    that.setData({

                        image_src: datas.data.url

                    })

                    that.image_src = datas.data.url

                }

            })

        }

    })

},

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

3 个回答

  • Frank
    Frank
    2022-05-09

    瞎搞

    2022-05-09
    有用 2
    回复
  • 武曲心
    武曲心
    2022-05-09

    拿小程序和web做比较是啥意思?还有这url是认真的?

    2022-05-09
    有用
    回复
  • 欢乐马
    欢乐马
    2022-05-09

    不知道

    2022-05-09
    有用
    回复
登录 后发表内容