2012-12-18 34 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编辑之后,它已成为语法无效的代码。这不可能工作。 –