• <bdo id='S2go9'></bdo><ul id='S2go9'></ul>
  1. <small id='S2go9'></small><noframes id='S2go9'>

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

      一个让用户从我的网站下载文件而不泄露我网站中实际文件链接的 PHP 脚本?

      时间:2023-08-20
      • <bdo id='nD4Ry'></bdo><ul id='nD4Ry'></ul>
      • <small id='nD4Ry'></small><noframes id='nD4Ry'>

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

                <legend id='nD4Ry'><style id='nD4Ry'><dir id='nD4Ry'><q id='nD4Ry'></q></dir></style></legend><tfoot id='nD4Ry'></tfoot>
                本文介绍了一个让用户从我的网站下载文件而不泄露我网站中实际文件链接的 PHP 脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                问题说明了一切.. 我如何让用户从我的网站下载文件而不是让他们看到该文件来自哪个链接?我知道可能需要像 download.php 这样的东西作为网关,但是过了那个阶段,我不知道接下来要编写什么脚本......代码,我应该需要使用的几个函数名称真的很方便!

                The question says it all.. How do I let the users download a file from my website and not let them see what link that file comes from? I understand that there might be a need for something like a download.php which will serve as the gateway but past that phase, I dunno what to script next... If it bothers you to write the whole code, a few function names that I should need to use would be really handy!

                推荐答案

                找到一种方法来识别要下载的文件(例如,与数据库中某行的 ID 匹配的 GET 变量,或类似的东西).确保它是有效的,因为您不希望您的用户能够从您的站点下载任何内容.然后,使用 headerContent-Disposition 告诉浏览器应该下载文件,readfile 输出它.

                Find a way to identify the file to download (for instance, a GET variable that matches the ID of a row in a database, or something along these lines). Make damn sure it's a valid one, because you don't want your users to be able to download anything off your site. Then, use header with Content-Disposition to tell the browser the file should be downloaded, and readfile to output it.

                例如:

                <?php
                
                $id = intval($_GET['id']);
                $query = mysql_query('SELECT file_path FROM files WHERE id = ' . $id);
                if (($row = mysql_fetch_row($query)) !== false)
                {
                    header('Content-Disposition: attachment; filename=' . basename($row[0]));
                    readfile($row[0]);
                }
                exit;
                
                ?>
                

                这篇关于一个让用户从我的网站下载文件而不泄露我网站中实际文件链接的 PHP 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:下载与存储名称不同的文件 下一篇:使用 php 下载文件,而不是处理大文件?

                相关文章

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

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

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