Html 有关本地文件的相对路径链接的帮助
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6342854/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Help with relative path link to local file
提问by drbunsen
This is a very basic html question, but I can't seem to locate the answer.
这是一个非常基本的 html 问题,但我似乎找不到答案。
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:
在位于 /Main 目录中的 .html 文档中,我可以foo.txt
使用完整路径链接到该文件:
<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?
我想使用相对路径链接到foo.txt
. 有谁知道如何创建该foo.txt
文件的相对路径链接?
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.
提前致谢。任何帮助表示赞赏。
回答by Francis Gilbert
Remove the file:///
part to have just ../June/foo.txt
.
拆下file:///
零件刚好../June/foo.txt
。
This should help you out.
这应该可以帮助你。
回答by P.Hoxha
If you simply drag your file from the solution explorer into the razor/html page, it will create for you everything you need.
如果您只是将文件从解决方案资源管理器拖到 razor/html 页面中,它将为您创建所需的一切。