PHP创建多级目录 文件夹

/**
 * 创建多级目录
 *
 * @param [type] $path
 * @return void
 */
function my_mkdir($path)
{
    if (is_dir($path)) {
        // echo "目录 " . $path . " 已经存在!";
        return true;
    } else {
        //第三个参数是“true”表示能创建多级目录,iconv防止中文目录乱码
        // $res=mkdir($path,0777,true);
        $res = mkdir(iconv("UTF-8", "GBK", $path), 0777, true);
        if ($res) {
            // echo "目录 $path 创建成功";
            return true;
        } else {
            // echo "目录 $path 创建失败";
            return false;
        }
    }
}

 

posted @ 2020-05-21 17:16  xiondun  阅读(200)  评论(0编辑  收藏  举报