2013-03-17 66 views
0

基于分配给用户的唯一代码,是否有任何良好的开放,预制库或其他文件下载系统?基于代码的文件下载

这里的想法是生成一组代码,让每个用户使用他的代码来下载文件。优选地,具有对下载时间的可定制限制和/或时间限制。

如果没有,关于如何实现这个好主意将不胜感激。

回答

1

为了生成这些代码,您可以使用一个函数来生成一个随机字符串或者简单的PHP本地rand()函数。然后在db中创建一个表格,其中包含您生成的代码以及与其关联的文件的位置。

该文件的download.php应该被称为是这样的:哈希的download.php = generated_code

,看起来像这样:

<?php 
// Retrieve filename and file location on the disk from the db 
header('Content-disposition: attachment; filename='.$sql_response['filename']); 
readfile($sql_response['filelocationondisk']); 
?> 

您也可以使用cookie或计算量下载限制限制通过IP在数据库中下载。