Take the 2-minute tour ×

I'm trying to implement a solution that allows a user to upload a file but will not let them upload another file for another 24 hours after doing so. I imagine a MySQL table entry that gets flagged when the user submits a file and then 24 hours later I need the flag to change back to allow upload again.

Additionally, I want to make it so when a user does upload a file, it is referenced and stored by the MySQL table allowing the user to see what files they have uploaded and remove it if they want to. This would also need to delete the uploaded file from the shared directory.

Can someone point me in the right direction for this? I'm not asking for the work to be done for me, just curious what method I would use for this.

share|improve this question
You can't stop someone from uploading a file, other than NOT showing the upload form. But you could keep the upload handler from wasting its time if <24 hours has elapsed by simply ignoring the upload. –  Marc B Oct 11 '12 at 18:08
add comment

2 Answers

You could use a before-insert trigger and check the last insertion's date. And if the insert is too early then throw an exception.

share|improve this answer
add comment

If you have a database that has two tables in it - one for users and one capturing the files uploaded by users, keep a datetime_uploaded column in the latter table. When users land on the page allowing them to upload files, perform a query that returns the most recent file they uploaded.

If the date and time it's less than 24 hours ago, don't provide the user with the form. Otherwise allow the upload.

share|improve this answer
add comment

Your Answer


