2013-07-26 49 views
0

從下載管理器中的下載鏈接在PHP中,我們可以做這樣的事情如何隱藏在PHP

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

下載文件。但是,該URL將在諸如DAP之類的下載管理器中可見。那麼真的有辦法隱藏下載URL嗎?

+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

+0

添加文件名 – Sundar

+0

我在我的Chrome瀏覽器中試過了。彈出錯誤消息,說:「從服務器收到的重複標題」。 –