1

I want to save canvas as local image file, I have see HTML5 Canvas to PNG File, and try:

<a id="dl" download="Canvas.png">Download Canvas</a>
<script>
function dlCanvas() {
    var dt = canvas.toDataURL('image/png');
    this.href = dt.replace(/^data:image\/[^;]/, 'data:application/octet-stream');
};
dl.addEventListener('click', dlCanvas, false);
</script>

but in chrome, the browser never open the file dialog and let me choose where to save, but I want to choose a directory, how should I do.

Community
  • 1
  • 1
hzqij1978
  • 263
  • 2
  • 9
  • Chrome already has a "Save Image As" option if you right-click the canvas. – enhzflep May 26 '15 at 11:15
  • but I don't want to manual right-click the canvas and choose "Save Image As" – hzqij1978 May 26 '15 at 12:19
  • Then your needs seem to require that you instruct users to change the settings of their browsers. Reading your question along with the following link leads me to think that you've currently got Firefox set to "Always ask me where to save files" and that in Chrome this option is not picked. The link I mention is this one: http://www.wikihow.com/Choose-Where-a-Download-is-Saved – enhzflep May 26 '15 at 12:29

0 Answers0