I have a mobile html page which contains images. I want to create a button or a link which is used for a download of an image. The image should then be saved to the users mobile image gallery.
The solution
is working in desktop browsers but not on mobile.
Note: The image is created in the browser i.e., in a HTML5 canvas element. This image can be generated with canvas.toDataUrl(). The resulting image should be saved to the mobile image gallery.
How can save an image to the users mobile image gallery with a click/tap? Is there a JavaScript solution without the ser round trip with a unknown header?
解决方案
Somebody seems to have answered this already,
It's not yet fully supported http://caniuse.com/#feat=download, but you can use with modernizr
http://modernizr.com/download/#-a_download (under Non-core detects) to
support all browsers.
Have not tested, but should work in mobiles as well.
I would add that, as a server side solution, you could also add Response Headers to your download endpoint by
Setting it up in apache (.htaccess) / nginx configuration
Right from the code