Question

I'm practicing some file upload with PHP and I was uploading a file numerous times, so I wanted to make sure I wasn't taking up a lot of space on the server. I had a while loop go over every file in the php tmp directory, and there were 103,988 entries.

Is this more than normal? I had assumed the tmp directory was for files that were automatically deleted after a certain amount of time. Am I supposed to be managing this folder some how?

Part of the reason I ask is because I'm writing an app that takes a users file, changes some things, and serves it back to them. I want the file to be deleted once they leave, but I'm not sure what the best way to do it is. Should I have a folder I put all the files in and use cron to delete files older than a certain time?

Was it helpful?

Solution

General rule is that you should clean up after yourself whenever possible.

If you aren't sure that you can remove temporary files every time, it is a good idea to have a cron job doing this for you once in a while.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top