Click here to Skip to main content
15,886,798 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Im using this command to download a file when I click on the download button in my website

HTML
<a href="text.txt" download>download </a>


its working perfectly but when I go to for example https://website.com/text.txt it does not download automatically how can I make it do so?

What I have tried:

I have tried removing the download text but that doesn't work
Posted
Updated 16-Oct-22 5:31am

1 solution

There is no way to force a download from that link when the page loads. That's just not an option.

You would have to use javascript to download the file automatically. Some examples:
https://stackoverflow.com/questions/3916191/download-data-url-file[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900