Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP way to find the web server's temp path?

Tags:

path

php

upload

When you handle an HTTP upload the file is uploaded to

$_FILES['field_name']['tmp_name']

I know I could extract the temp path from there. But I was expecting maybe a $_SERVER param that had the temp path (there's none) or other elegant way of knowing it.

Is there any?

like image 438
Petruza Avatar asked Oct 05 '09 16:10

Petruza


People also ask

How to get temp file path in PHP?

$fh = fopen("/var/www/html/myfile. xml", 'w') or die("no no"); fwrite($fh, $fileData); fclose($fh);

Which file is used to set the location of temporary directory in PHP?

In this example, it is "/var/tmp": ; Directory where the temporary files should be placed. Click OK to apply the changes. Now, add the new path (in this example, it is "/var/tmp") to open_basedir of all domains, so that PHP scripts can access this directory.

What are PHP TMP files?

The tmpfile() function in PHP is an inbuilt function which is used to create a temporary file with a unique name in read-write (w+) mode. The file created using tmpfile() function gets automatically deleted when close using fclose() or when there are no remaining references to the file handle.

What is Upload_tmp_dir?

Overview. The temporary directory is used for storing files when a file is uploaded. This directory must be writable by whichever user PHP is running as. If not specified, PHP will use the system's default.


1 Answers

ini_get('upload_tmp_dir');
like image 188
Waleed Amjad Avatar answered Sep 25 '22 20:09

Waleed Amjad