How to upload the pictures generated by WeChat Mini Programs canvas to the server?

Hello, everyone.
I have a need now, that is, I can sign it manually in Mini Program, and then upload it to the server. I use canvas to sign on the screen, but I won"t upload it to the server
use the wx.uploadFile provided by Wechat not to send a web request at all

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){

            }
        })
    }
})
Mar.05,2021

have never played Mini Program, but you use localhost? Wechat does not know whether your localhost bar


has been solved or not. If you have solved the trouble, thank you qq 2531947025


. Please tell


did you report it correctly?

clipboard.png

have you configured it here?


is there a stutter problem with your canvas tablet?

Menu