: When and how do I remove temporary files on server left from abandoned forms? I have a form on my site to submit posts, it features multiple file upload tool (Mini Ajax File Upload Form)
I have a form on my site to submit posts, it features multiple file upload tool (Mini Ajax File Upload Form) which submits files to server as they are added (before actual post submission) and server then stores them in temp dir. Once article has been submitted, all associated files are stored to uploads dir and temp dir is cleared.
How should I clean temp dir from files left after posts where files were added but which were never submitted? Should I do it just from time to time using, say, cron script or is it better to do whenever site scripts run?
Post submission must be anonymous (with captcha or some more difficult verification), so I'm concerned with server being stuffed with files from abandoned forms.
More posts by @Marchetta884
2 Comments
Sorted by latest first Latest Oldest Best
I'd go in reverse order.
Make file submission happen last then use crontab to delete garbage data at frequent intervals.
If the data being submitted is small enough, then use PHP sessions or cookies to store the basic information then when the files are submitted, then store the basic info from the cookies or sessions to the database and then you won't have to worry about deleting files.
Do you write to 2 different tables like...
tblTmpUpload
id
file_path
timestamp
tblUpload
id
file_path
otherstuff
timestamp
If so, you could query the tblTmpUpload and look for files w/ a timestamp more than 24 hours old and remove the file based on file path stored.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.