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

How to creat working download button

20th Feb 2019, 9:47 AM
Mohammed Safeer
Mohammed Safeer - avatar
4 Answers
+ 10
Some Other Ways.... Way#1 <form method="get" action="file.doc"> <button type="submit">Download!</button> </form> Way#2 <button type="submit" onclick="window.open('file.doc')">Download!</button> Way#3 (Bootstrap Version) <a class="btn btn-danger" role="button" href="path_to_file" download="proposed_file_name"> Download </a>
20th Feb 2019, 10:17 AM
shovan
shovan - avatar
+ 11
I have done some research and found the best answer. You can trigger a download by using the new HTML5 download attribute. <a href="path_to_file" download="proposed_file_name">Download</a> Where : *path_to_file is either an absolute or relative path, *proposed_file_name the filename to save to (can be blank, then defaults to the actual filename). Hope this is helpful.
20th Feb 2019, 10:12 AM
shovan
shovan - avatar
+ 5
<a download href="downloads/file.zip"> Download Fonts </a>
20th Feb 2019, 10:27 AM
shovan
shovan - avatar
+ 1
The best solution is: <a href="file" download>Download</a> *Just you need to use 'download' after href property you can use your button within the <a> tag
23rd Feb 2019, 5:44 PM
Aimlessly