html2canvas javascript screenshot and upload

后端 未结 3 467
广开言路
广开言路 2021-02-04 12:34

Would it be possible to use html2canvas (This) to take a picture of the user`s screen but also upload the image, get the upload link and send it with ajax to the webserver?

3条回答
  •  臣服心动
    2021-02-04 13:13

    This isn't tested, but should work

    function screenshot() {
        html2canvas(document.body).then(function(canvas) {
            // post using your favourite xhr polyfill, e.g. jQuery's
            $.post('http://urlgoeshere.com', canvas.toDataURL('image/png'));
        });
    }
    

    Then decode the result from base64 on the server side and put in a file

提交回复
热议问题