Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download file using anchor tag <a>

Tags:

html

Why is this not working:

download.html

<a href="jsplogin.jar">download</a> 

The jsplogin.jar file is in the same folder has the download.html file.

when I click the download link the file jsplogin.jar should download but its trying to open the file in the browser. when I right clicked on the link and selected "save link" nothing is happening.

like image 411
Coder17 Avatar asked Feb 06 '14 15:02

Coder17


People also ask

How do I download using anchor tag?

Approach 1: Using Download attribute The download attribute simply uses an anchor tag to prepare the location of the file that needs to be downloaded. The name of the file can be set using the attribute value name, if not provided then the original filename will be used.

How do I download an anchor tag from a PDF?

Explains the way to use the anchor tag with download attribute to force a file download. HTML5 introduced the download attribute of the anchor tag to add downloadable behavior to it. We can use the anchor tag to download a file by specifying the name of the downloadable file.

How do I download an HTML file?

You can also right-click anywhere on the page and select Save as or use the keyboard shortcut Ctrl + S in Windows or Command + S in macOS. Chrome can save the complete web page, including text and media assets, or just the HTML text.


1 Answers

In HTML5, in most browsers you can add a 'download' attribute to the a element.

for example:

<a href="http://www.example.com/index.html" download>Download</a> 

Based on this question. How can I create download link in html?

like image 193
captainrad Avatar answered Oct 09 '22 21:10

captainrad