10

I've built a simple web app which creates an image from a canvas element using canvas.toDataURL(). I then create an anchor tag using the data URI, containing a download attribute. Something like this:

<a href="data:image/jpeg;base64,somedata" download="filename.jpg">Download</a>

This works great on Android/MacOS devices on Chrome and Safari - clicking the anchor downloads the data URI as a .jpg file.

But on iOS Chrome clicking the link does nothing. To download the file it requires opening the anchor in a new tab (which displays the image), then saving the image.

I have tried adding a target="_blank" but that does not achieve the desired result.

Is there a way to make iOS work like Android/MacOS, where clicking the link initiates the download?

Brett DeWoody
  • 55,478
  • 28
  • 131
  • 182
  • I don't think you can download files on iOS like you can on other devices. It's really different since it doesn't have the same type of file system as normal devices. – Charlie Fish Dec 29 '18 at 18:14
  • check this https://stackoverflow.com/questions/53666113/file-not-downloading-with-blob-object-in-iphone-chrome-browser. Using FileReader can resolve this issue. but only for ios. – Micheal Vu Jan 09 '20 at 02:35

0 Answers0