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

时间:2013-07-26 06:40:47

标签: php url download

在PHP中,我们可以执行类似

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

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

1 个答案:

答案 0 :(得分:0)

//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);
?>

MIME类型信息

http://filext.com/file-extension/EXE