iOS webview: Prompt an user to download image using only JavaScript
I'm experimenting with letting the iPhone user draw using the canvas and then having a link to download the work.
I can get the image to load on a "new page" via:
window.location.href = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
Whereby the user can "copy" the image and paste it in an email. The user can also take a screen shot using the native iPhone ability.
What I would prefer is to do something like开发者_运维百科 this:
window.location.href = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
Unfortunately that leads to a "Safari can't download this file" error.
Any ideas from here? I would like the ability to not have to download this file serverside just to offer it up to the user again.
Safari does not allow file downloads. You would just have to display the image, and let them hold down their finger on it and click the save button (to save to camera roll).
精彩评论