How to add download button to my website? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to add download button to my website?

21st Nov 2016, 4:41 AM
Aadhityan R P
Aadhityan R P - avatar
4 Answers
+ 3
You can do: <form method="get" action="path_to_file/file.zip"> <button type="submit">Download</button> </form> or even better (with html5): <a href="path_to_file" download="file.zip> <button>Download</button> </a>
21st Nov 2016, 7:24 AM
Rustam Klekit
Rustam Klekit - avatar
+ 2
the above code by @Rustam gives you the solution but to let you know how it works. When you create a link with '<a href' and point it to the file in the server, the browser tries to read and interpret in the browser but it can't interpret anything other html so if you point to a zip file, doc or ppt then the browser tries to download it by default.
21st Nov 2016, 8:01 AM
Surya Konduru
Surya Konduru - avatar
+ 2
thank you
21st Nov 2016, 8:21 AM
Aadhityan R P
Aadhityan R P - avatar
0
Surya is right
25th Nov 2016, 8:11 PM
Alex King
Alex King - avatar