-5
A
回答
5
您可以使用身份驗證系統,並且不會將公開網址呈現給下載程序。 例如,創建一個表,如:
file_name | file_path | file_code
-------------------------------------------------------
My picture | /var/docs/img.jpg | kljsldjalksdqhq1218
而在用戶登錄(並滿足您定義的標準)後,你送他的下載鏈接:
http://yoursite.com/index.php?page=download&file=kljsldjalksdqhq1218
然後您查詢數據庫,檢查正確的關聯,然後讀取文件 - 位於文檔根btw之外,例如使用file_get_contents()
,並將其作爲八位字節流或其他適當的MIME用於文件類型,以強制文件下載;
header('Content-Type: "'.$mime.'"');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary");
header('Expires: 0');
header('Pragma: no-cache');
header("Content-Length: ".strlen($file));
10
只是阻止URL'HTTP:沿東西線使用的htaccess或使用不同的方法 – 2012-04-24 20:40:53
,這取決於你的需要和情況,你有沒有發佈。 – Lalajee 2012-04-24 20:42:08
@Lalajee // YourSite/downloadAllResumes' – Brad 2012-04-24 21:09:45