简体   繁体   中英

How to download a file given a relative file path (Angular)?

This is my html:

<button class="btn" (click)="generatePdf()">PDF</button>

When the button is clicked, generatePdf generates the relative url (/var/folders...) for the pdf. How do I download this file from the relative url?

Thanks for your help!

. Hi Beatrice,

To setup a download on your website, you would add an <a> tag with the href attribute set to the path to your PDF that you want to download.

<!-- Uploaded file in same location as HTML file -->
<a href="examplefile.pdf" download>Link text</a>

I hope that this was able to help!

phylo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM