This is crazy but I don\'t know how to do this, and because of how common the words are, it\'s hard to find what I need on search engines. I\'m thinking this should be an ea
Another way of doing in case you have a complex URL such as file.doc?foo=bar&jon=doe
is to add hidden field inside the form
<form method="get" action="file.doc">
<input type="hidden" name="foo" value="bar" />
<input type="hidden" name="john" value="doe" />
<button type="submit">Download Now</button>
</form>
inspired on @Cfreak answer which is not complete
What about:
<input type="button" value="Download Now!" onclick="window.location = 'file.doc';">
I think this is the solution you were looking for
<button type="submit" onclick="window.location.href='file.doc'">Download!</button>
I hade a case where my Javascript generated a CSV file. Since there is no remote URL to download it I use the following implementation.
downloadCSV: function(data){
var MIME_TYPE = "text/csv";
var blob = new Blob([data], {type: MIME_TYPE});
window.location.href = window.URL.createObjectURL(blob);
}
download attribute do it
<a class="btn btn-success btn-sm" href="/file_path/file.type" download>
<span>download </span> <i class="fa fa-download"></i>
</a>
HTML:
<button type="submit" onclick="window.open('file.doc')">Download!</button>
Bootstrap Version
<a class="btn btn-danger" role="button" href="path_to_file"
download="proposed_file_name">
Download
</a>
Documented in Bootstrap 4 docs, and works in Bootstrap 3 as well.