KeithMcCloy
KeithMcCloy

Reputation: 1

How do I link to a local file in HTML

I have tried the methods suggested in my book and in the questions in a chat group, but I just get a "File Not Found" error.

These are typical of what I have tried:

<A HREF="file:///C:/DBAR.txt">Local File</A>

and

<A HREF="file://////C:/DBAR.txt">Local File</A>

I noticed that the Chrome address bar contains the string:

file:///filepath to my HTML file. The above address in quotation marks. I assume that the first part of this is my problem, but I do not know why it is there or how to change it, if that is my problem. Any help would be appreciated.

Upvotes: 0

Views: 5618

Answers (1)

VinceKaj
VinceKaj

Reputation: 335

If the file you are trying to open is in the same directory as the page you can use href="FILENAME". If it's not in the same directory you can either put a slash before the "filepath" for example href="/Desktop/FILENAME".

You don't need to write "file:///filepath". just write the directory and that's it.

Upvotes: 2

Related Questions