Solved

PHP TMP Directory

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

825 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