Reputation: 2452
I am creating a website , which people can create their own video and can download it from my server.
I want to limit the download count to 10.
So What I am planning is to serve a download file via a php file and update the count of the file to database.If it reaches 10 downloads.I deny the download.
But I guess it consume more resource.Is there any other way possible in linux server such as using htaccess or something like that ? So after a file is accessed 10 times it should be automatically deleted.
EDIT : its not users...any people can use this website for free.
Upvotes: 3
Views: 1936
Reputation: 378
If you don't want to avoid DB queries for this you can apply a simple technique in filename to indicate remaining limit Like filename-10, filename-9 etc. But to use this approach u need to update the part after "-" on each download.
This could be one approach.
Upvotes: 4
Reputation: 2817
I one of the simplest solution,
in the user profile folder store the file in the file system and when the counter in the database reaches 10 then use unlink()
method in php to delete that file.
Upvotes: 0