drbunsen
drbunsen

Reputation: 10709

How to use a relative path to link to another local file?

This is a very basic html question, but I can't seem to locate the answer.

I have a local file located here:

/Users/Me/Desktop/Main/June/foo.txt

In an .html document located within the /Main directory, I can link to the foo.txt file using the full path:

<a href="file:///Users/Me/Desktop/Main/June/foo.txt">Full Path Link</a>

I would like to use relative paths to link to foo.txt. Does anyone know how to create a relative path link to this foo.txt file?

I tried the code below and a number of similar permutations, but I can't seem to successfully write the relative path link for this local file.

<a href="file:///../June/foo.txt">Relative path Link</a>

Upvotes: 41

Views: 111722

Answers (2)

P.Hoxha
P.Hoxha

Reputation: 25

If you simply drag your file from the solution explorer into the razor/html page, it will create for you everything you need.

Upvotes: -2

Francis Gilbert
Francis Gilbert

Reputation: 3442

Remove the file:/// part to have just ../June/foo.txt.

This should help you out.

Upvotes: 54

Related Questions