0

If you wan't to download a file in HTML you can just put a download tag like the following:

<a href="downloads/path" download>Download file</a>

In my application you can search for a project and then you can download the files to it. I can perfectly search after the files and I get them displayed as I want. So then I tried to download them, but however it won't work.

Here is my HTML code:

<div *ngFor="let file of FILES">
   <a href="{{file.downloadUrl}}" download>{{file.name}}</a>
</div>

The problem now is, the files opens himself in the browser, but it should download itself. I am really confused at this point, because it is literally like it should be (atleast I think so)

Gion Rubitschung
  • 741
  • 11
  • 31
  • Possible duplicate of [Force to open "Save As..." popup open at text link click for PDF in HTML](https://stackoverflow.com/questions/3802510/force-to-open-save-as-popup-open-at-text-link-click-for-pdf-in-html) – Maihan Nijat May 29 '19 at 15:46
  • @MaihanNijat I actually read through this question, but this download link in my question is builded up the same way as the solutions in the [answers](https://stackoverflow.com/questions/3802510/force-to-open-save-as-popup-open-at-text-link-click-for-pdf-in-html/17280071#17280071) of this question. – Gion Rubitschung May 29 '19 at 15:52
  • Read the comments also. – Maihan Nijat May 29 '19 at 15:53

1 Answers1

0

Most modern browsers are set to read documents by default if they can instead of downloading them are you using the same browser and experiencing different results for the same links? The browser can decide not to download a pdf even if you use download in the anchor tag. The issue is covered in this other post pretty well: PDF file not downloading with HTML5 download attribute

DanGo
  • 391
  • 1
  • 13