React : Link to PDF which is in my project folder [duplicate] - html

This question already has answers here:
React - How to open PDF file as a href target blank
(6 answers)
Closed 1 year ago.
In my React application, I want to link to a PDF from a page.
The PDF is located in src\assets\, and I have my component in src\components\xyz\.
In my component, I simply do <a href="<link to pdf>" >Download here</a>, but clicking on this takes me to localhost:3000/foo.pdf which doesn't give me anything.
When I add a download attribute to a it downloads the file, but I want it to first open in a new tab and then the user can download it from there.
How do I achieve this?

You can put the path to document in url href like this and try.
Download

Related

Open local file on a local disk c: throught HTML page href link [duplicate]

This question already has answers here:
How can I create a link to a local file on a locally-run web page?
(5 answers)
Closed 2 years ago.
I'm trying to open a file on my local disk c: throught a link on my personal web page.
using this:
open locally
on the new "_blank" page, the url bar appears like "file///C:/myfolder/myfile.pdf", the colon (:) was removed from "file:///". The local file doesn't open just because the colon is missed.
What am I doing wrong? How can i fix it?
Try structuring your link like this
Open Locally
You do not need to add the blank window conditional as it will open with what ever your default PDF viewer is.
Remove "http://"
open locally
Local file protocol is "file://"

Cannot download a file off <a> link [duplicate]

This question already has answers here:
How to specify a local file within html using the file: scheme?
(5 answers)
Closed 3 years ago.
I try to put a link to a file in my page, such that, once a user clicks the link - the browser downloads the file.
HTML:
<a href="correct_path...." download>downloadable link</a>
Here is the image shows the full path of the link:
And here is the image shows the file does exist:
So why, when I click the link NOTHING happens? it doesn't download..
When you work with a server (local server too) the root of the urls/links must be the server, not your computer.
For example, in your case, if the root folder of your server is 'SMIS' the correct URL will be "http://localhost/SMIS/Files/6.pdf"

Download Not working through HTML anchor tag [duplicate]

This question already has answers here:
Linking to local content in a web application
(2 answers)
How to specify a local file within html using the file: scheme?
(5 answers)
Closed 4 years ago.
We are using GoLang as backend and AngularJS as frontend. The backend sends a file path as response and in the UI, I need to consume the file path and download it. The filepath is local machine path.
In HTML
<td *ngIf="hasPackageDownloadPermission">
<div class="package-icons">
</span>
</div>
</td>
From Dev Tools
<div class="package-icons">
<a download="" target="_blank" ng-reflect-href="file:///home/usern/bbbb1014_pokg1039.tar" href="file:///home/usern/bbbb1014_pokg1039.tar"><span class="fa fa-download" title="Download"></span></a>
</div>
In Chrome:
Getting Failed - Network Error
In FireFox:
Nothing happens on click.
If I simply copy paste the file path that is returned as response, in chrome file is downloading. In firefox a confirmation dialog appears to ask whether to 'save file'.

How to allow users to choose download directory with download tag? [duplicate]

This question already has answers here:
How to forcefully open the file browser to save the file before downloading? [duplicate]
(2 answers)
Influence browser download destination
(4 answers)
Closed 4 years ago.
HTML 5 has a download attribute which allows a user to download a file. But how can I allow the user to choose in which File directory they want to download file?
<a class="downnb" href="http://buhehe.de/wp-content/uploads/2018/m/1.jpg" download="filename">Download</a>
Clicking on them triggers just download file. But can I choose where?

adding an image from my computer in html [duplicate]

This question already has answers here:
How can I create a link to a local file on a locally-run web page?
(5 answers)
Closed 6 years ago.
I'm following online tutorials to start learning HTML and I'm having trouble adding an image. What I'm doing is just typing into a txt (renamed as .html and with UTF-8 encoding, per the tutorial's instructions) document, then checking to see the code changes work properly by opening. However I cant seem to get the image to load properly when testing it, no matter what I do. Here is what I have in the text document:
<img src="C:\users\jason\desktop\website\curved.jpg">
I double checked that the path is correct, everything is spelled correctly, and that image is in the same folder as the html document. So what am I doing wrong here?
Try using the file:/// protocol if you want to link to local files.
<img src="file:///C:\users\jason\desktop\website\curved.jpg">
Just double check that it is in fact a .jpg and not a .png for example, and try the following:
<img src="curved.jpg">
I would also have the image saved in the same folder as the HTML file.