首页 > 解决方案 > 如何显示非公共网站文件夹中的 .pdf 文件?

问题描述

我在网站的非公共文件夹中有几个 .pdf 文件。该文件夹名为“protected”,与 public_html 文件夹位于同一文件夹中。所有网站页面都是 .php 文件。

以下 HTML 代码正确显示 .txt 文件的内容:

<form method="post" action="../protected/documents/test.txt">
  <input name="submit1" type="submit" value="Text File" />
  <br>                      
</form>

以下代码返回 404 错误:

<form method="post" action="../protected/test.pdf">
  <input name="submit2" type="submit" value="PDF File" />
  <br>                      
</form>

为什么 .txt 文件可以正常显示而 .pdf 文件不能正常显示?

标签: phphtml

解决方案


你试过了吗

<a href="./protected/test.txt" target="_blank">TXT File</a>
<a href="./protected/test.pdf" target="_blank">PDF File</a>

推荐阅读