2012-12-18 35 views

回答

2

看看使用readfileheader將文件內容傳遞到頁面,並使用會話來跟蹤用戶訪問鏈接的次數。

-2

做一個index.php文件有:

if(!isset($_GET['hash'])) throw new Exception("Missing hash"); 

if(!isset($_GET['file'])) throw new Exception("Missing filename."); 

if(!isset$_GET['hash'] == md5($_SERVER['REMOTE_ADDR'])) throw new Exception("Invalid hash"); 

header('Location: http://domain/files/'. $_GET['file']); 

鏈接它像的index.php哈希= HASH &文件= filetodownload.exe?

+0

除了這是一個糟糕的解決方案,它會*總是*重定向到實際的文件感謝b0rken條件。 -1 –

+0

這正是海報想要它做的。您可以再建立幾個檢查文件是否存在等。如上所述;您可以使用標題和讀取文件來修改標題並強制用戶下載文件 – Youri

+0

@Youri編輯之後,它已成爲語法無效的代碼。這不可能工作。 –