更改 PHP 文件上传的默认临时目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15692705/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 09:45:38  来源:igfitidea点击:

Change default temp directory for PHP file uploads

phpfile-upload

提问by David C

I'm making a website locally that allows the upload of .pdf files, when these are uploaded locally they go to C:\xampp\tmpbut when I host the site on my University server I don't have access to the temporary directory, is there any way I can change the default temporary location for the file?

我正在本地创建一个允许上传 .pdf 文件的网站,当这些文件在本地上传时,它们会转到,C:\xampp\tmp但是当我在我的大学服务器上托管该站点时,我无法访问临时目录,有什么办法吗?可以更改文件的默认临时位置吗?

Thanks in advance, Dave.

提前致谢,戴夫。

回答by Oswald

The location where uploaded files land can be configured using the upload_tmp_dirconfiguration option.

上传文件所在的位置可以使用upload_tmp_dir配置选项进行配置。

回答by Yur Gasparyan

Try this.

尝试这个。

putenv('TMPDIR=/path/to/dir');

than you can check your tmp directory

比你可以检查你的 tmp 目录

sys_get_temp_dir()

回答by dy'sback

I do not believe that you had no right of access to the tempdirectory. In tempdirectory are stored session data.

我不相信您无权访问该temp目录。在temp目录中存储会话数据。

You should check temp direcory using:

您应该使用以下方法检查临时目录:

sys_get_temp_dir()