Raspberry Pi Apache2 未使用 HTML 访问用户文件
Raspberry Pi Apache2 not accessing the user files using HTML
我正在尝试为我的 Raspberry pi 编写一个 HTML 网页,该网页安装了 apache2 服务器。当我使用下面的代码时,图像和下载文件似乎没有显示在网页上。请有人告诉我问题是什么。
<i>
<body>
<header>
<img src="/home/admins/LOGO.png" alt="LOGO" width="450" height="100">
</header>
<hr>
</nav>
<article>
<h1>Result Download</h1>
<p> <br /> <br /><br/> </p>
<a href="/home/admins/Data.txt" download="DataFile" >
<img align = "centre" border="0" src="/home/admins/Download.png" alt="Download" width="120" height="150">
</a>
</article>
</section>
<footer>
<p>©Copyright 2018</p>
</footer>
</body>
</i>
which is having apache2 server installed
所以你大概是通过 HTTP 加载文件。
/home/admins/LOGO.png
…但是这个URL好像是本地文件系统上的一个文件路径。
Apache 的默认配置不会将文件系统的根目录 (/
) 视为网站的根目录。
这将是一个巨大的安全问题,因为它会暴露计算机上的每个文件(包括密码文件)!
相反,它希望文件位于为网站预留的目录中。这通常是 /var/www/
但使用 the DocumentRoot
directive.
配置
如果您想通过 HTTP 公开文件,请将其移入 DocumentRoot 或配置 an Alias
以将 URL 映射到文件。
我正在尝试为我的 Raspberry pi 编写一个 HTML 网页,该网页安装了 apache2 服务器。当我使用下面的代码时,图像和下载文件似乎没有显示在网页上。请有人告诉我问题是什么。
<i>
<body>
<header>
<img src="/home/admins/LOGO.png" alt="LOGO" width="450" height="100">
</header>
<hr>
</nav>
<article>
<h1>Result Download</h1>
<p> <br /> <br /><br/> </p>
<a href="/home/admins/Data.txt" download="DataFile" >
<img align = "centre" border="0" src="/home/admins/Download.png" alt="Download" width="120" height="150">
</a>
</article>
</section>
<footer>
<p>©Copyright 2018</p>
</footer>
</body>
</i>
which is having apache2 server installed
所以你大概是通过 HTTP 加载文件。
/home/admins/LOGO.png
…但是这个URL好像是本地文件系统上的一个文件路径。
Apache 的默认配置不会将文件系统的根目录 (/
) 视为网站的根目录。
这将是一个巨大的安全问题,因为它会暴露计算机上的每个文件(包括密码文件)!
相反,它希望文件位于为网站预留的目录中。这通常是 /var/www/
但使用 the DocumentRoot
directive.
如果您想通过 HTTP 公开文件,请将其移入 DocumentRoot 或配置 an Alias
以将 URL 映射到文件。