0

I want the canvas content to be saved as an image upon clicking a button. The button's OnClientClick() is attached to the following method. What it does is, it downloads the image and hence I needed an element of which the id is "link".

Can someone help me to get it saved to a location that I want ? I mean, I need to be able to specify the location for the file.

  <script type="text/javascript">
    function CanvasToImage() {
        var dataURL = can.toDataURL('image/png');
        document.location.href = dataURL.replace("image/png", "image/octet-stream");
        link.download = "test.png";
        link.href = canvas
            .toDataURL("image/png")
            .replace("image/png", "image/octet-stream");
        link.click();
    }
</script>
Roman
  • 4,922
  • 3
  • 22
  • 31
Prasadika
  • 897
  • 2
  • 20
  • 36
  • https://stackoverflow.com/questions/10673122/how-to-save-canvas-as-an-image-with-canvas-todataurl –  Aug 22 '17 at 05:58
  • [Save files into selected directory (javascript)](https://stackoverflow.com/questions/20888867/save-files-into-selected-directory-javascript) – Rudolf Manusachi Aug 22 '17 at 06:00

0 Answers0