41

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>
starball
59.7k53 gold badges317 silver badges1k bronze badges
asked Jun 14, 2011 at 11:34
2
  • 4
    why don't you just type: <a href="../June/foo.txt">Relative path Link</a> Commented Jun 14, 2011 at 11:36
  • The problem with your file:/// is you do not include the hard drive path. example file:///C:/Users/Me/Desktop/Main/June/foo.txt Commented May 12, 2016 at 14:51

2 Answers 2

54

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

This should help you out.

Mr_Green
42k48 gold badges171 silver badges277 bronze badges
answered Jun 14, 2011 at 11:38
Sign up to request clarification or add additional context in comments.

Comments

-2

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

answered Mar 24, 2016 at 13:23

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.