收藏
回答

图片上传报错

报错信息:

VM6374:1 uploadFile:fail createUploadTask:fail Error: Invalid URL passed to App.getProxyForURL()'


upFileHandler () {

    wx.chooseImage({

        count: 1, 

        success (res) {

            const tempFilePaths = res.tempFilePaths

            wx.uploadFile({

                url: '',

                filePath: tempFilePaths[0],

                name: 'image',

                formData: {

                    'imgIndex': 0

                },

                header: {

                "Content-Type": "multipart/form-data"  

                },

                success: function (res) {

                    var data = JSON.parse(res.data);

                }

            });

        }

    })

}


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

3 个回答

  • Promise
    Promise
    2020-07-22

    ??? 官方人没人理?

    2020-07-22
    有用
    回复
  • 是小白啊
    是小白啊
    2019-06-04

    麻烦提供能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)

    2019-06-04
    有用
    回复 1
  • 2019-06-04

    upFileHandler () {

        wx.chooseImage({
            count: 1,
            success (res) {

                const tempFilePaths = res.tempFilePaths

               // tempFilePaths[0] -> http://tmp/wx47292e19a83b70a2.o6zAJs4K2DBooYSRIZKPzqGyX0JU.lMeMD2yX89WWf0be879ebe2af232739edf76c3432313.jpg

                wx.uploadFile({
                    url: '',
                    filePath: tempFilePaths[0],
                    name: 'image',
                    formData: {
                        'imgIndex': 0
                    },
                    header: {
                        "Content-Type": "multipart/form-data" 
                    },
                    success: function (res) {
                        var data = JSON.parse(res.data);
                    }
                });
            }
        })
    }

    整理一下格式,在调用这个方法时,就会报错

    uploadFile:fail createUploadTask:fail Error: Invalid URL passed to App.getProxyForURL()'


    2019-06-04
    有用
    回复
登录 后发表内容