微信小程序 canvas 生成的图片 如何上传到服务器?

大家好,
我现在有一个需求,就是在小程序中让可以手动签名,然后上传到服务器。我用 canvas 实现了在屏幕上签名,但是不会上传到服务器
用微信提供的 wx.uploadFile 根本连网络请求都不发

wx.canvasToTempFilePath({
    canvasId: 'myCanvas',
    success: function (res) {
        var path = res.tempFilePath;
        console.log(path)
    
        wx.uploadFile({
            url: 'http://localhost/e_contract/public/index.php/member/index/test',
            filePath: path,
            name: 'file',
            formData: {
                'user': 'test'
            },
            header: { "Content-Type": "multipart/form-data", 'Cookie': 'PHPSESSID=' + overall.json.token},
            success: function (res) {
                var data = res.data
                console.log(res);
                //do something
            },
            fail:function(res){

            }
        })
    }
})
阅读 9.5k
5 个回答

没玩过小程序,但你用localhost?微信不知道你的localhost吧

新手上路,请多包涵

解决了没我也遇到了,如果解决了麻烦告知下 谢了 qq 2531947025

新手上路,请多包涵

解决了吗 麻烦告知

你没有报错吗?

clipboard.png

你这里配置了吗?

推荐问题