Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you set filename for "save as" on an image with a data url?

Tags:

javascript

I have an image like this:

<img src="data:image/jpeg;charset=utf-8;base64,/9j...">

When I right click on the image and choose 'save as', the save dialog comes up with "download.jpg" as the filename. I'd like to choose a different default filename. Adding a download tag on the img element doesn't seem to work. Is there some way to add a name to this?

I've seen this, but its about <a> tags: Is there any way to specify a suggested filename when using data: URI?

like image 418
B T Avatar asked Aug 19 '16 08:08

B T


1 Answers

Maybe you can try something like this using caman.js. Here is a example how it works. I know that it's not exactly what you want but take a look. DEMO

You can also use the <a> tag to do that but it will download on click.

<a download="logo.png" href="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">Download transparent png</a>
like image 123
Edison Biba Avatar answered Oct 17 '22 16:10

Edison Biba