Sai Rajesh Sai Rajesh - 3 months ago 8
HTML Question

how to download sample text file when i click the link?

I have to download following

sample.txt
file when i click the link. How to add download option?

<a href="">Please Download Sample file</a>



sample.txt


hello world...

Answer

Use the href to link to the document that you want the user to download. So you need to have the url to what should be downloaded, or point to it on your server. Adding download to the html markup will have it download, better to leave it to the user to decide though...

<a href="http://www.pdf995.com/samples/pdf.pdf" download>Click to download</a>