If for whatever reason, you cannot add the download attribute in the case that you cannot directly edit the HTML of your web page , you can optionally compress the file using zip, and instruct the user to download the zip file. You can alternatively explain to the user that they should right click on the link and select download.
If you have no other alternatives to force the file to download, you can host it on a file hosting service such as Google Docs. The most common file types that are affected by this behavior are PDF files and images. The code below will tell the browser to prompt the user to save the file.
This link does not have the download attribute. This link has the download attribute. Verbal Ability. Interview Questions. Company Questions. Artificial Intelligence. Cloud Computing. Data Science. Angular 7. Machine Learning. Data Structures. Operating System. Computer Network.
Compiler Design. Computer Organization. Discrete Mathematics. Ethical Hacking. Computer Graphics. Software Engineering. Web Technology. Cyber Security. C Programming. Control System. Data Mining. Data Warehouse. Which browser are you using? Perfect - the download attribute should work in most updated versions of Chrome so you should be good from that angle. Add a comment. Active Oldest Votes. Download Basics So essentially what is happening is that when you link to a file URL, the browser opens that URL and if it has accessibility to display the content, it almost always will.
Improve this answer. Why am I getting a mins point for that answer. If you want I can clarify my answer. But the presented solution is solving the problem and is working perfectly - the pdf does not open, but instead gets downloaded! Adi Rahman Adi Rahman 1 1 1 bronze badge. Sign up or log in Sign up using Google.
Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. A conversation about how to enable high-velocity DevOps culture at your Podcast An oral history of Stack Overflow — told by its founding team.
0コメント