Solved

PHP TMP Directory

Posted on 2006-11-25
5
712 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Not needed 13 58
PHP loop not working 4 33
Apostophes in PHP generated form 6 18
Return data with AJAX, JQUERY and PHP 13 38
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 …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now