0

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?

mowwwalker
  • 16,634
  • 25
  • 104
  • 157

1 Answers1

2

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.

sanmai
  • 29,083
  • 12
  • 64
  • 76
  • 1
    ..or use a stochastic mechanism - like session garbage collection. Still its a good idea to run this outside of the page generation - but that doesn't necessarily mean asynchronously (see register_shutdown_function()) – symcbean Jan 23 '12 at 10:45