在upload上传图片时发现无法上传成功,通过官方资料发现TMPDIR目录未指定。

FastCGI sent in stderr: “PHP message: PHP Notice: Unknown: file created in the system’s temporary directory in Unknown on line 0PHP message: PHP Warning: Unknown: open_basedir restriction in effect. File/tmp is not within the allowed paths: /wwwroot in Unknown on line 0PHP message: PHP Warning: File upload error – unable to create a temporary file in Unknown on line 0” while reading response header from upstream

<?php
    echo sys_get_temp_dir() . PHP_EOL;
?>

[root@php-server ~]#php /wwwroot/aa.php 
/tmp

解决

修改 php-fpm配置文件

env[TMP] = /wwwroot/tmp
env[TMPDIR] = /wwwroot/tmp
env[TEMP] = /wwwroot/tmp
其他问题

修改完成后又有报错

FastCGI sent in stderr: “PHP message: PHP Notice: Unknown: file created in the system’s temporary directory in Unknown on line 0PHP message: PHP Warning: File upload error – unable to create a temporary file in Unknown on line 0” while reading response header from upstream, client:

解决方法

忘记创建临时目录,将临时目录创建并赋予用户组权限后重启php服务

觉得上面的内容有用吗?快来点个赞吧!

点赞() 我要打赏

温馨提示 : 本站内容来自会员投稿以及互联网,所有源码及教程均为作者总结编辑,请大家在使用过程中提前做好备份,以免发生无法预知的错误,源码类教程请勿直接用于生产环境!

 可能感兴趣的文章