• <legend id='F8QAk'><style id='F8QAk'><dir id='F8QAk'><q id='F8QAk'></q></dir></style></legend>

  • <tfoot id='F8QAk'></tfoot>
        • <bdo id='F8QAk'></bdo><ul id='F8QAk'></ul>

        <small id='F8QAk'></small><noframes id='F8QAk'>

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

      1. 如何密码保护网站中可下载的pdf文件

        时间:2023-08-20

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

                <small id='zualB'></small><noframes id='zualB'>

                  <tbody id='zualB'></tbody>
                  <tfoot id='zualB'></tfoot>
                • 本文介绍了如何密码保护网站中可下载的pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个个人作品集网站,我有一些 pdf 文件,例如

                  I am having a personal portfolio website and i have a some pdf files like

                  <a href="file.pdf">Some file</a>
                  

                  我不想让每个人都下载这个文件,我想让它用密码保护它,这样我就可以只和我认识的人分享

                  I dont want everyone to download the file, and i want it to protect it with password,so that i can share it with only the people i know

                  只有提供正确密码的人才能下载我的文件

                  where only the person who gives the correct password is able to download my file

                  注意:1. 由于是个人作品集网站,所以没有任何登录"
                  2. 我用HTML设计了网页作为响应式代码

                  Note: 1. since its a personal portfolio website it do not have any "LOGIN's"
                  2. I have designed the webpage with HTML as a responsive code

                  请提供您的建议,没有 .htaccess 的任何方法??

                  Your suggestions please, any way of doing it without .htaccess ??

                  推荐答案

                  使用 MySQL 或 MySQLite - 根据您的偏好 - 并将 PDF 链接存储在数据库中.然后使用诸如download.php 之类的脚本.在数据库中存储文件的密码,并要求用户在下载文件之前输入密码.如果您不熟悉数据库,您可以用 PHP 完成所有工作.

                  Use MySQL or MySQLite - depending on your preference - and store the link to the PDF in the database. Then use a script such as download.php. Store a password for the file in the database and require the user to enter it before the file is downloaded. If you're unfamiliar with databases you COULD do it all in PHP.

                  一个非常粗糙的模型(没有数据库,如果你熟悉dbs,请相应调整)

                  A VERY rough mockup (Without a database, if you are familiar with dbs, adjust accordingly)

                  HTML 表单

                  <form name="download" id="download" method="post" action="download.php">
                    <input type="password" id="password" name="password" />
                    <input type="submit" id="submit" value="Download" />
                  </form>
                  

                  PHP (下载.php)

                  PHP (download.php)

                  <?php
                       // Get the password
                            $pw = md5($_POST['password']);
                  
                       // Compare against the stored password
                            $valid_pw = md5("your password you want to use");
                  
                            if($pw != $valid_pw){
                                 echo "Error! You do not have access to this file";
                            }else{
                                 header("Location: /path/to/your/file.pdf");
                            }
                  ?>
                  

                  注意:

                  我使用了一种非常基本的密码加密方法.如果这是我的应用程序,我会研究更好的方法,但为了简洁和易于理解,我使用了一个简单的 md5() 哈希比较.

                  I used an extremely basic method of encrypting the password. I would research better methods if this was my application but for the sake of brevity and ease of understanding, I used a simple md5() hash comparison.

                  这篇关于如何密码保护网站中可下载的pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:强制浏览器下载文件而不是打开文件 下一篇:需要php脚本下载远程服务器上的文件并保存到本地

                  相关文章

                  <tfoot id='3FxUS'></tfoot>

                  1. <small id='3FxUS'></small><noframes id='3FxUS'>

                      <bdo id='3FxUS'></bdo><ul id='3FxUS'></ul>

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