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

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"

Related

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

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

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://"

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.

<a href="http://file://///> convert file:// to file// ---remove colon [duplicate]

This question already has answers here:
Linking a UNC / Network drive on an html page
(3 answers)
Closed 6 years ago.
I need to open filelink (network share in local) in the browser.
I use such code:
<a href="http://file://///server/localfolder">
It open link in the browser but convert it to such format:
file/////server/localfolder (remove colon).
This way browser don't open local folder.
I have tried to change file:///// to file:// or file:/// or file://// . But colon stell removed by browser.
How to solve it?
You can't specify more than one protocol definition as part of a URL schema. You shouldn't link to file:// either, really, but if you absolutely must, just remove the http:// definition as follows:
<a href="file:///server/localfolder">
You can read more about file: protocol, and in particular its implementation in the following links:
Wikipedia Article
Another SO question (with very good answer)