Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does PHP save temporary files during uploading?

Tags:

I am using XAMPP on Windows. By printing $_FILES["file"]["tmp_name"], it seems that the temporary file was saved at C:\xampp\tmp\phpABCD.tmp. But I cannot see it on the filesystem of the server. However, the file can be moved or copied via move_uploaded_file(), rename(), or copy(). So where does PHP actually save temporary files during uploading?

like image 305
powerboy Avatar asked Sep 28 '10 22:09

powerboy


People also ask

Where does temporary files get stored?

Temp files often have the extension . TMP and are stored in the C:\Users\AppData\Local\Temp folder. If you're working on a document, your word-processing app may create a temporary file to track your progress. If the app crashes, you'll be able to recover your data from the temp file.

How do I access my uploaded files in PHP?

In PHP, we can access the actual name of the file which we are uploading by keyword $_FILES[“file”][“name”]. The $_FILES is the by default keyword in PHP to access the details of files that we uploaded. The file refers to the name which is defined in the “index. html” form in the input of the file.

Which PHP script variable specifies the path of the file to be uploaded?

$target_file specifies the path of the file to be uploaded.

Where is the tmp directory?

In Unix and Linux, the global temporary directories are /tmp and /var/tmp. Web browsers periodically write data to the tmp directory during page views and downloads. Typically, /var/tmp is for persistent files (as it may be preserved over reboots), and /tmp is for more temporary files.


2 Answers

It saves it at the path specified in $_FILES["file"]["tmp_name"], but deletes it after the script is done executing. It's up to you to move the file elsewhere if you want to preserve it.

like image 184
Matthew Avatar answered Sep 20 '22 03:09

Matthew


Its specified in upload_tmp_dir in your php.ini file. It is deleted by the system automatically after use.

like image 40
bpeterson76 Avatar answered Sep 21 '22 03:09

bpeterson76