Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Disable Uploading Within a Time Limit

Tags:

php

upload

limit

How can I keep a client from uploading more after having uploaded something within a time limit? Based on IP address.

like image 852
user580889 Avatar asked Jan 28 '26 03:01

user580889


1 Answers

Basing your disabling on the user's IP address is ineffective. In addition to what Kel said, the client also may have a dynamic IP, or be using Tor.

Really the only way would be to force the user to identify him/herself in some way. There are lots of options out there: Facebook, OpenID, Twitter, etc. You could create a user account system for your site, but that would be much more inconvenient for the user; using an infrastructure that's already in place would be better.

As for the more technical side of things, basically you'll keep a database table of users that have uploaded files, and a timestamp column that holds the time that they uploaded. You'll regularly traverse this table with a Cron job, and remove users that are older than a pre-defined threshold.

When a person attempts to upload, check if they're in the database. If they are, they can't upload; if they aren't, they're good to go.

like image 131
Jonah Avatar answered Jan 29 '26 19:01

Jonah