How do I get the PHP Uploads directory?
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
$tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir();
Php file upload temporary directory is a php config variable located on php.ini file.
You can get the variable config value by using ini_get
function.
$path = ini_get('upload_tmp_dir');
// your code here
$upload_dir = ini_get('upload_tmp_dir');
精彩评论