链接到更高级别文件夹中的文件

iva*_*txo 4 html file href

我在处理比我的根文件夹更高级别的文档时遇到了麻烦.

<a href='../../home/folder/document.docx'>Proposal</a>
Run Code Online (Sandbox Code Playgroud)

在浏览器中,上面的内容被解释为:

http://localhost/home/folder/document.docx
Run Code Online (Sandbox Code Playgroud)

我看不到浏览器在文件夹中出现,然后我得到的答案是:

Not Found
The requested URL /home/folder/document.docx was not found on this server.
Run Code Online (Sandbox Code Playgroud)

我在Firefox和Chrome上试过,它也是一样的.我在Linux机器上使用Apache Web Server.

任何帮助将不胜感激.

Ric*_*ers 6

您无法将访问者重定向到文档根目录之外的文件(您拥有index.html).人们看不到文件高于http://localhost/最终的文件.

解决方案是将它.docx放在文档根目录(index.html所在的位置)中.

但是,您可以使用readfile函数让PHP为该文件提供服务.但不要忘记,www-data需要访问您正在服务的文件.