Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PHP中从下载管理器隐藏下载链接_Php_Url_Download - Fatal编程技术网

如何在PHP中从下载管理器隐藏下载链接

如何在PHP中从下载管理器隐藏下载链接,php,url,download,Php,Url,Download,在PHP中,我们可以执行以下操作 <?php header("Location: https://www.example.com/test.exe"); ?> 下载一个文件。但是,URL将在下载管理器(如DAP)中可见。那么,真的有办法完全隐藏下载URL吗?//这将对您有所帮助 //This will help you <?php $fullpath = 'https://www.example.com/test.exe'; $filename ='test.exe'

在PHP中,我们可以执行以下操作

<?php
 header("Location: https://www.example.com/test.exe");
?>

下载一个文件。但是,URL将在下载管理器(如DAP)中可见。那么,真的有办法完全隐藏下载URL吗?

//这将对您有所帮助
//This will help you

<?php
$fullpath = 'https://www.example.com/test.exe';
$filename ='test.exe';
header("Cache-Control: public, must-revalidate");
header("Content-Type: application/exe");
header("Content-Length: " .(string)(filesize($fullpath)) );
header('Content-Disposition: attachment; filename="'.$filename.'"');                 
readfile($fullpath);
?>

生成一个随机字符串,与数据库建立链接(字符串->计算机上的文件),当用户请求一个文件时,链接被生成,然后当它被使用时,链接被删除。我在我的Chrome浏览器中尝试了它。弹出一条错误消息:“从服务器接收到重复的头”。