Mobile app version of vmapp.org
Login or Join
Marchetta884

: 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)

@Marchetta884

Posted in: #Cms #Files #Php #Post #Uploading

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.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Marchetta884

2 Comments

Sorted by latest first Latest Oldest Best

 

@Angela700

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.

10% popularity Vote Up Vote Down


 

@Vandalay111

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme