Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the PHP Uploads directory?

Tags:

php

I have uploaded a file using HTML / PHP and following is the print_r() of the $_FILES['file'] array:

Array
(
    [name] => Chrysanthemum.jpg
    [type] => application/octet-stream
    [tmp_name] => G:\xampp\tmp\php82DB.tmp
    [error] => 0
    [size] => 879394
)

As you can see above, the temp file is stored in the tmp_name directory. I need to get that directory path using PHP. How do I get it ?

Tried using sys_get_temp_dir() but this is what it returns me.

I do NOT want to get the directory from the array or from the file upload data. I want to dynamically get the php file uploads directory using a function.

C:\Users\admin\AppData\Local\Temp
like image 201
YD8877 Avatar asked Sep 22 '11 08:09

YD8877


1 Answers

$tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir();
like image 99
xdazz Avatar answered Oct 09 '22 04:10

xdazz