PHP 创建目录时抛错,Warning: mkdir(): Permission denied in xxx.php on line 45的解决办法

如下, PHP 创建目录时抛错,Warning:  mkdir(): Permission denied in aerchi_file_upload_parser.php on line 45

$cur_root_upload_path = $_SERVER['DOCUMENT_ROOT']."/aerchi/upload-2019/";
//创建目录失败
if (!file_exists($cur_root_upload_path ) && !mkdir($cur_root_upload_path , 0777, true)) {
    $data_result['msg'] = "ERROR_CREATE_DIR";
    // return;
} else if (!is_writeable($cur_root_upload_path )) {
    $data_result['msg'] = "ERROR_DIR_NOT_WRITEABLE";
    // return;
}

"Warning:  mkdir(): Permission denied in /usr/www/2019/aerchi/admin/aerchi_file_upload_parser.php on line 45
{"code":1,"msg":"guhua.jpg \u4e0a\u4f20\u5b8c\u6210.","time":"20190814 01:39:48","filepath":"\/aerchi\/upload-2019\/guhua.jpg"}"

解决方法: 

1. 赋予权限

chown -R nginx /usr/www/2019/aerchi/upload-2019/* && chmod 755 -R /usr/www/2019/aerchi/upload-2019/*

2. 查看路径,必须要以 域名相对路径 /usr/ 开始,如无,请添加.

$cur_root_upload_path = $_SERVER['DOCUMENT_ROOT']."/aerchi/upload-2019/";

 

 

发布了430 篇原创文章 · 获赞 415 · 访问量 925万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览