I want to force a pdf to be downloaded on mobile/tablet device to avoid open it in a new tab.
I tried with the download
attribute:
<a href="file.pdf" download target="_blank">
It works on desktop but not on mobile.
I also tried with PHP header
:
header('Content-Type: application/pdf');
header('Content-Transfer-Encoding: Binary');
header('Content-Disposition: attachment; filename="file.pdf"');
readfile('https://my-website.com/file.pdf');
But same, it works on desktop but not on mobile.
Any way to do this?
application/octet-stream
was a trick to force the download, I wouldn't be surprised if that still works these days, unless sniffing is getting smarter. That said, I also wouldn't be surprised if iOS very specifically ignored this and did whatever they wanted