+ 1

Download

Please can someone teach how to connect download button to a file on a website so that when you click on it it will download

1st Jul 2024, 6:20 PM
Alhassan Emmanuel
Alhassan Emmanuel - avatar
4 Réponses
+ 2
and also the file should be downloadable, not like .php; make sure it is accessible (has the right permissions) and don't store .exe, .dll, .ocx and similar files directly. at least compress to zip (zip is the preferred one) without password request. but .7z is still okay.... for Linux preferred: .tar.gz, .tar.bz2, .tar.xz and yes, use href for it. I hope this helps
1st Jul 2024, 7:42 PM
Mihaly Nyilas
Mihaly Nyilas - avatar
+ 1
Often times it just connects to an href URL of the file.
1st Jul 2024, 6:50 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
+ 1
Here's what I found on web search from SO https://stackoverflow.com/questions/11620698/how-to-trigger-a-file-download-when-clicking-an-html-button-or-javascript No one perfect answer you will find there, each and every answer has their good & bad. So it's up to you to implement it in your code and see which one works best for your project. Good luck!
2nd Jul 2024, 7:52 AM
Ipang
+ 1
If you must require a button. Just nest the link in the button element. <button><a href="your file path" download="yourfilename">Download</a></button> The download attribute will preset the file name.
2nd Jul 2024, 8:05 AM
Chris Coder
Chris Coder - avatar