?
Solved

PHP TMP Directory

Posted on 2006-11-25
5
Medium Priority
?
718 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 2000 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
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.
Suggested Courses

762 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