javascript - Save canvas as jpg to desktop -


this question has answer here:

i trying save image (jpeg) desktop html5canvas. can open in new window window.open(canvas.todataurl('png'), "");, how can save desktop? thanks.

download attribute

there new download attribute in html5 allow specify file-name links.

i made saving canvas. has link ("download image") -

<a id="downloadlnk" download="yourfilename.jpg">download image</a> 

and function:

function download() {     var dt = canvas.todataurl('image/jpeg');     this.href = dt; }; downloadlnk.addeventlistener('click', download, false); 

you can change file-name dynamically setting attribute downloadlnk.download = 'myfilename.jpg'.

demo archives.


Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -