Solved

PHP TMP Directory

Posted on 2006-11-25
5
715 Views
Last Modified: 2012-06-21
Hi! I was wondering how temporary files are handled when uploaded in php... Uploaded files are initially stored in the tmp directory - do they get automatically deleted or does it have to be done manually ? Is it done by php, do I have to write a script or is it done by the server periodically, e.g. Cron ?
0
Comment
Question by:Julian Matz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 29

Expert Comment

by:TeRReF
ID: 18012401
You use move_uploaded_file() for this purpose:
http://php.net/manual/en/function.move-uploaded-file.php
0
 
LVL 21

Author Comment

by:Julian Matz
ID: 18012421
Hi TeRReF,

Yes, I know about that function, but I was thinking about files that maybe fail to get moved, etc.
Does that make sense ? Session data gets stored there too, doesn't it ?

Just looked into the server's tmp directory - there's a lot of session data but only very recent... But there are also some files there that are a couple of months old - one of them seems to be an image:

Oct 15 01:45 phpaMbFwY.jpg
0
 
LVL 29

Accepted Solution

by:
TeRReF earned 500 total points
ID: 18012462
Hi Julian,

You're right, by default, session data is stored there as well. Those older files are probably interrupted uploads or something similar.

Usually it's not necessary to clean up your /tmp dir, unless it's on a small partition. Most *NIX systems clean the /tmp dir after a reboot or with a cron job of their own. Also, most tmp files are only a couple of KB's so they won't fill up /tmp that easily.

Since you have files that are a couple of months old, either your server has been up quite a while now or there is no automatic cleaning in place. So, if you do want to remove some PHP specific junk from it, I think a cron job will serve you well.
0
 
LVL 21

Author Comment

by:Julian Matz
ID: 18109526
Thanks!
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 18110456
You're welcome :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question