1、在 Postman 中打开网址:http://api.pcs.wjdev.chinamcloud.cn/v1/assets/upload, 上传文件,响应失败,如图1
2019-09-29 17:19:34 [10.42.165.54][8][-][warning][yii/validators/FileValidator::validateValue] Missing the temporary folder to store the uploaded file: 360wallpaper(0).jpg in /mcloud/www/pcs-api/api/rests/asset/UploadAction.php:84
2、查看 /runtime/logs/app.log,报错:[warning][yii/validators/FileValidator::validateValue] Missing the temporary folder to store the uploaded file: 360wallpaper(0).jpg
3、回退至上一版本,未报错,查看 Git 日志,分析差异,如图2
4、查看 File Uploads 的 upload_tmp_dir 值,;upload_tmp_dir =,上传文件时用于存储文件的临时目录。任何运行PHP的用户都必须可写。如果未指定,PHP将使用系统的默认值。系统的默认临时目录为 /tmp,查看当前版本 /tmp 目录的权限,如图3
drwxrwxr-x 1 root root
5、查看上一版本 /tmp 目录的权限,权限方面存在差异,分析得出结论,原因在于:/tmp 目录被覆盖进而导致权限被修改,如图4
drwxrwxrwt 1 root root
6、将 /build/c_files/tmp/yii-cmc-console-user-sync.ini、/build/c_files/tmp/yii-config-column-user-sync.ini 剪切至 /build/c_files/mcloud/yii-cmc-console-user-sync.ini、/build/c_files/mcloud/yii-config-column-user-sync.ini,如图5
7、编辑 /build/c_files/config/init/console_init.sh,替换 /tmp 为 /mcloud,代码如下,如图6
env | grep PCS_API_CFG_CONSOLE || export PCS_API_CFG_CONSOLE="false" if [[ $PCS_API_CFG_CONSOLE == "true" ]] then /cp /mcloud/yii-cmc-console-user-sync.ini /etc/supervisord.d/ echo "复制 yii-cmc-console-user-sync.ini 至 /etc/supervisord.d/" /cp /mcloud/yii-config-column-user-sync.ini /etc/supervisord.d/ echo "复制 yii-config-column-user-sync.ini 至 /etc/supervisord.d/" elif [[ $PCS_API_CFG_CONSOLE == "false" ]] then echo "copy without console" else echo "please set environment variable PCS_API_CFG_CONSOLE true or false" fi
8、在 Postman 中打开网址:http://api.pcs.wjdev.chinamcloud.cn/v1/assets/upload, 上传文件,响应成功,如图7
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/181406.html