• <small id='f3oHQ'></small><noframes id='f3oHQ'>

  • <legend id='f3oHQ'><style id='f3oHQ'><dir id='f3oHQ'><q id='f3oHQ'></q></dir></style></legend>
      <i id='f3oHQ'><tr id='f3oHQ'><dt id='f3oHQ'><q id='f3oHQ'><span id='f3oHQ'><b id='f3oHQ'><form id='f3oHQ'><ins id='f3oHQ'></ins><ul id='f3oHQ'></ul><sub id='f3oHQ'></sub></form><legend id='f3oHQ'></legend><bdo id='f3oHQ'><pre id='f3oHQ'><center id='f3oHQ'></center></pre></bdo></b><th id='f3oHQ'></th></span></q></dt></tr></i><div id='f3oHQ'><tfoot id='f3oHQ'></tfoot><dl id='f3oHQ'><fieldset id='f3oHQ'></fieldset></dl></div>

          <bdo id='f3oHQ'></bdo><ul id='f3oHQ'></ul>
        <tfoot id='f3oHQ'></tfoot>

      1. 为 PDF 创建安全文件托管服务器

        时间:2023-10-30
        • <bdo id='0rRNp'></bdo><ul id='0rRNp'></ul>
            <tbody id='0rRNp'></tbody>
            <legend id='0rRNp'><style id='0rRNp'><dir id='0rRNp'><q id='0rRNp'></q></dir></style></legend>

              <i id='0rRNp'><tr id='0rRNp'><dt id='0rRNp'><q id='0rRNp'><span id='0rRNp'><b id='0rRNp'><form id='0rRNp'><ins id='0rRNp'></ins><ul id='0rRNp'></ul><sub id='0rRNp'></sub></form><legend id='0rRNp'></legend><bdo id='0rRNp'><pre id='0rRNp'><center id='0rRNp'></center></pre></bdo></b><th id='0rRNp'></th></span></q></dt></tr></i><div id='0rRNp'><tfoot id='0rRNp'></tfoot><dl id='0rRNp'><fieldset id='0rRNp'></fieldset></dl></div>

              <small id='0rRNp'></small><noframes id='0rRNp'>

            1. <tfoot id='0rRNp'></tfoot>
                  本文介绍了为 PDF 创建安全文件托管服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在开发一个网站,允许客户登录并查看保存在服务器上的各种 PDF.这些 PDF 对客户端来说是唯一的,不应该被未登录的人访问.将文件放到服务器上应该不是问题,我只是不确定如何将它们提供给最终用户.

                  I'm working to develop a website that allows clients to log in and see various PDFs saved on the server. These PDFs will be unique to the client and should not be accessible by someone who is not logged in. Getting the files onto the server shouldn't be an issue, I'm just not sure on how to serve them to end users.

                  我已经通过提供来自 SQL 服务器 的数据而不是文件来实现这种事情,所以我不完全确定最有效的方法是什么.

                  I've implemented this kind of thing with data from SQL servers being served instead of files, so I'm not entirely sure what the most effective way to go about this.

                  该网站位于 LAMP 上,而我在 PHP 方面的经验最少(但如果框架或其他语言能让这变得更容易,我可以学习它).

                  The website is on a LAMP and my minimal experience is in PHP (but if a framework or other language would make this easier, I can learn it).

                  我可能有点不知所措,但我通常是这样,所以任何输入都会很棒.

                  I'm probably in over my head but I usually am, so any input would be great.

                  推荐答案

                  将文件放在 webroot 之外.然后使用 PHP 通过脚本传递文件.这样,没有人可以直接链接到文件并绕过您的控制.(当然要确保只有在验证用户有权检索该文件后执行此操作的脚本).

                  Put the files outside of the webroot. Then using PHP pass the file though a script. That way no one can link to the file directly and bypass your controls. (Naturally make sure the script that does this only after verifying the user has permission to retrieve that file).

                  示例 PHP:

                  <?php
                      session_start();
                      if (!isset($_SESSION['authenticated'])) {
                          exit;
                      }
                      $file = '/path/to/file/outside/www/secret.pdf';
                  
                      header('Content-Description: File Transfer');
                      header('Content-Type: application/octet-stream');
                      header('Content-Disposition: attachment; filename=' . basename($file));
                      header('Content-Transfer-Encoding: binary');
                      header('Expires: 0');
                      header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                      header('Pragma: public');
                      header('Content-Length: ' . filesize($file));
                      ob_clean();
                      flush();
                      readfile($file);
                      exit;
                  ?>
                  

                  这篇关于为 PDF 创建安全文件托管服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何获取上传到 FTP 服务器的文件的 HTTP URL 下一篇:如何确定文件是否仍在通过 ftp 传输

                  相关文章

                1. <small id='QONPR'></small><noframes id='QONPR'>

                  1. <tfoot id='QONPR'></tfoot>
                      <bdo id='QONPR'></bdo><ul id='QONPR'></ul>
                      <i id='QONPR'><tr id='QONPR'><dt id='QONPR'><q id='QONPR'><span id='QONPR'><b id='QONPR'><form id='QONPR'><ins id='QONPR'></ins><ul id='QONPR'></ul><sub id='QONPR'></sub></form><legend id='QONPR'></legend><bdo id='QONPR'><pre id='QONPR'><center id='QONPR'></center></pre></bdo></b><th id='QONPR'></th></span></q></dt></tr></i><div id='QONPR'><tfoot id='QONPR'></tfoot><dl id='QONPR'><fieldset id='QONPR'></fieldset></dl></div>

                      <legend id='QONPR'><style id='QONPR'><dir id='QONPR'><q id='QONPR'></q></dir></style></legend>