Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 更改tempnam中的位置_Php_Codeigniter_Codeigniter 2 - Fatal编程技术网

Php 更改tempnam中的位置

Php 更改tempnam中的位置,php,codeigniter,codeigniter-2,Php,Codeigniter,Codeigniter 2,在tempnam()中提供目录路径时遇到一些问题。当我使用tempnam(''xyz'),文件将存储在tmp目录中。但我需要将文件永久存储在特定目录中。我正在使用CodeIgniter。我想将文件保存在文件夹docs中,该文件夹与application和system位于同一目录中。我应该在tempnam()中给出什么位置?更新:我尝试提供位置路径ietempnam($\u SERVER['DOCUMENT\u ROOT']./exotel/docs,'xyz')但文件仍保存在tmp文件夹中RTL

tempnam()中提供目录路径时遇到一些问题。当我使用
tempnam(''xyz')
,文件将存储在
tmp
目录中。但我需要将文件永久存储在特定目录中。我正在使用CodeIgniter。我想将文件保存在文件夹
docs
中,该文件夹与
application
system
位于同一目录中。我应该在
tempnam()中给出什么位置
更新:我尝试提供位置路径ie
tempnam($\u SERVER['DOCUMENT\u ROOT']./exotel/docs,'xyz')但文件仍保存在
tmp
文件夹中

RTLM:

根据上述文档,如果指定的目录不存在,tempnam()可以使用系统temp dir。您正在指定一个空字符串目录(
'
),该目录将不存在,因此PHP可以自由使用它想要的任何目录

试一试


相反。

请参阅有关tempnam的文档。第一个参数是目录

文档中的示例:

<?php
$tmpfname = tempnam("/tmp", "FOO");

$handle = fopen($tmpfname, "w");
fwrite($handle, "writing to tempfile");
fclose($handle);

// do here something

unlink($tmpfname);
?>


我试图给出
$temp\u file\u uri=tempnam($\u SERVER['DOCUMENT\u ROOT']./exotel/docs,'xyz')甚至它仍将进入
tmp
文件夹。文档目录存在于
/var/www/exotel/docs
中,我试图给出
$temp\u file\u uri=tempnam($\u SERVER['DOCUMENT\u ROOT']./exotel/docs','xyz')甚至它仍将进入
tmp
文件夹。文档目录位于
/var/www/exotel/docs
<?php
$tmpfname = tempnam("/tmp", "FOO");

$handle = fopen($tmpfname, "w");
fwrite($handle, "writing to tempfile");
fclose($handle);

// do here something

unlink($tmpfname);
?>