[英]how to set and get temp folder/file for file upload in php
I was using the system default temp folder (C:\\Xampp\\tmp) for file uploads.我使用系统默认临时文件夹 (C:\\Xampp\\tmp) 进行文件上传。 But now I need to specify a temp folder to store the temp files before upload.
但是现在我需要在上传之前指定一个临时文件夹来存储临时文件。 Is this the right function?
这是正确的功能吗?
ini_set('upload_tmp_dir','../../tempuploads');
And how to get the file from there?以及如何从那里获取文件?
Till now I was using this:直到现在我一直在使用这个:
$file_tmpname = $_FILES["ctrlFileUpload"]["tmp_name"];
I hope this is possible.我希望这是可能的。
It's not temp file "before" upload but temp during and just after upload.它不是“之前”上传的临时文件,而是上传期间和之后的临时文件。 If your ini_set works file tmp_name will be okay and you just have to use move_uploaded_file after that tu push your file in a correct f
如果您的 ini_set 工作文件 tmp_name 就可以了,您只需要在之后使用 move_uploaded_file 将您的文件推入正确的 f
You can set upload_tmp_dir in the php.ini file:您可以在 php.ini 文件中设置 upload_tmp_dir:
Set upload_tmp_dir to a safe location将 upload_tmp_dir 设置为安全位置
upload_tmp_dir = /var/www/foo.bar/sessions
ini_set(‘upload_tmp_dir’, ‘/path/to/dir’);
The setting can also be applied in apache's httpd.conf file, or an .htaccess file:该设置也可以应用于 apache 的 httpd.conf 文件或 .htaccess 文件:
# Set upload_tmp_dir to a safe location
php_value upload_tmp_dir /var/www/xxx.bar/sessions
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.