perl cgi - 更改临时上传文件的位置

perl cgi - change location for temporary uploaded files

将现有脚本移至新服务器后,功能不再起作用:

$CGITempFile::TMPDIRECTORY = $TempFile::TMPDIRECTORY = $temp_dir;

我发现:"Changes in temporary file handling (v4.05+) : CGI.pm had its temporary file handling significantly refactored, this logic is now all deferred to File::Temp [...]" 您可以在此处完整阅读:Link to CGI doc

因此,我在 File::Temp(以及许多论坛)的文档中进行了搜索,但没有找到任何有关如何更改临时文件路径的信息。

非常感谢任何帮助!

P. S. 上下文看起来像这样

use CGI::Carp qw(fatalsToBrowser);
use CGI;
[...]
$CGITempFile::TMPDIRECTORY = $TempFile::TMPDIRECTORY = $temp_dir;
[...]
my $cg = new CGI;

非常感谢,Сухой27,感谢您的评论,解决方案非常简单(一旦您知道)我只是将上面的代码替换为:

$ENV{TMPDIR}=$temp_dir;