没有不值得去解决的问题,也没有不值得去学习的技术!

Resolving the “Missing the temporary folder to store the uploaded file” Error When Deploying With Rancher

Open the URL in Postman: http://api.pcs.wjdev.chinamcloud.cn/v1/assets/upload, upload a file, and the response fails

1. Open the URL in Postman: http://api.pcs.wjdev.chinamcloud.cn/v1/assets/upload, upload a file, and the response fails, as shown in Figure 1

Open the URL in Postman: http://api.pcs.wjdev.chinamcloud.cn/v1/assets/upload, upload a file, and the response fails
Figure 1
Plaintext

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. Check /runtime/logs/app.log, and the error is: [warning][yii\validators\FileValidator::validateValue] Missing the temporary folder to store the uploaded file: 360wallpaper(0).jpg

3. Roll back to the previous version, where no error occurs. Check the Git log to analyze the differences, as shown in Figure 2

Roll back to the previous version, where no error occurs. Check the Git log to analyze the differences
Figure 2

4. Check the upload_tmp_dir value under File Uploads, ;upload_tmp_dir =, which is the temporary directory used to store files when uploading. It must be writable by the user running PHP. If not specified, PHP will use the system default. The system’s default temporary directory is /tmp. Check the permissions of the /tmp directory in the current version, as shown in Figure 3

Check the upload_tmp_dir value under File Uploads, ;upload_tmp_dir =, which is the temporary directory used to store files when uploading. It must be writable by the user running PHP. If not specified, PHP will use the system default. The system's default temporary directory is /tmp. Check the permissions of the /tmp directory in the current version
Figure 3
Plaintext

drwxrwxr-x   1 root root

5. Check the permissions of the /tmp directory in the previous version. There is a difference in permissions. The analysis leads to the conclusion that the cause is: the /tmp directory was overwritten, which in turn caused the permissions to be modified, as shown in Figure 4

Check the permissions of the /tmp directory in the previous version. There is a difference in permissions. The analysis leads to the conclusion that the cause is: the /tmp directory was overwritten, which in turn caused the permissions to be modified
Figure 4
Plaintext

drwxrwxrwt   1 root root

6. Move /build/c_files/tmp/yii-cmc-console-user-sync.ini and /build/c_files/tmp/yii-config-column-user-sync.ini to /build/c_files/mcloud/yii-cmc-console-user-sync.ini and /build/c_files/mcloud/yii-config-column-user-sync.ini, as shown in Figure 5

Move /build/c_files/tmp/yii-cmc-console-user-sync.ini and /build/c_files/tmp/yii-config-column-user-sync.ini to /build/c_files/mcloud/yii-cmc-console-user-sync.ini and /build/c_files/mcloud/yii-config-column-user-sync.ini
Figure 5

7. Edit \build\c_files\config\init\console_init.sh, replacing /tmp with /mcloud. The code is as follows, as shown in Figure 6

Edit \build\c_files\config\init\console_init.sh, replacing /tmp with /mcloud
Figure 6
ShellScript

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. Open the URL in Postman: http://api.pcs.wjdev.chinamcloud.cn/v1/assets/upload, upload a file, and the response is successful, as shown in Figure 7

Open the URL in Postman: http://api.pcs.wjdev.chinamcloud.cn/v1/assets/upload, upload a file, and the response is successful
Figure 7

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系