Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
329 views
in Technique[技术] by (71.8m points)

javascript - 如何下载给定相对文件路径(角)的文件?(How to download a file given a relative file path (Angular)?)

This is my html:

(这是我的html:)

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

When the button is clicked, generatePdf generates the relative url (/var/folders...) for the pdf.

(单击按钮后,generatePdf会为pdf生成相对URL(/ var / folders ...)。)

How do I download this file from the relative url?

(如何从相对网址下载此文件?)

Thanks for your help!

(谢谢你的帮助!)

  ask by Beatrice translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

.

(。)

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.

(要在您的网站上设置下载,您需要添加<a>标签,并将href属性设置为要下载的PDF的路径。)

<!-- 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

(phylo)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...