Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help with relative path link to local file

Tags:

html

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> 

Thanks in advance. Any help is appreciated.

like image 266
drbunsen Avatar asked Jun 14 '11 11:06

drbunsen


People also ask

Can you hyperlink to a local file?

If you're using Windows 10, hold down Shift on your keyboard and right-click on the file, folder, or library for which you want a link. If you're using Windows 11, simply right-click on it. Then, select “Copy as path” in the contextual menu.

How do I create a relative path to a file?

Relative pathRelative paths make use of two special symbols, a dot (.) and a double-dot (..), which translate into the current directory and the parent directory. Double dots are used for moving up in the hierarchy. A single dot represents the current directory itself.

How do I make a relative link?

To link pages using relative URL in HTML, use the <a> tag with href attribute. Relative URL is used to add a link to a page on the website. For example, /contact, /about_team, etc.


1 Answers

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

This should help you out.

like image 130
Francis Gilbert Avatar answered Oct 05 '22 22:10

Francis Gilbert