0

I am trying to download canvas as an image in a specific folder. I have succeeded to download the image however it keeps going to the default chrome directory (Downloads folder) and I would like to change this.

sample code:

<script>
       function downloadImage() {
        var link = document.createElement('a');
        link.download = 'image.png';
        link.href = document.getElementById('canvas').toDataURL();
        link.click();
    }
</script>


<canvas height="400" width="400" id="canvasshow"></canvas>

Any idea how can I do this, I've searched all over the internet. Thanks

I've searched on the internet and all over stackoverflow ...

1 Answers1

0

You can set your browser so that it saves in another location, or that it asks every time where to save files. For Chrome, these settings are accessible at chrome://settings/downloads (you can enter that in the address bar).

However this will obviously work only for your browser and not for your users. But that's fine, because anyway you can't be sure what's your user file system will look like. For Chrome users, there is an API that we can use to force them to choose the destination, but that's still experimental.

Kaiido
  • 123,334
  • 13
  • 219
  • 285