ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
``` ~~~ /** * @param $path * @param int $type * @param bool $force * @return string * @throws Exception * @author: LuckyHhy <jackhhy520@qq.com> * @date: 2020/6/28 0028 * @describe:上传路径转化,默认路径 */ function make_path($path, int $type = 2, bool $force = false) { $path = DS . ltrim(rtrim($path)); switch ($type) { case 1: $path .= DS . date('Y'); break; case 2: $path .= DS . date('Y') . DS . date('m'); break; case 3: $path .= DS . date('Y') . DS . date('m') . DS . date('d'); break; } try { if (is_dir(app()->getRootPath() . 'public' . DS . 'uploads' . $path) == true || mkdir(app()->getRootPath() . 'public' . DS . 'uploads' . $path, 0777, true) == true) { return trim(str_replace(DS, '/', $path), '.'); } else return ''; } catch (\Exception $e) { if ($force) throw new \Exception($e->getMessage()); return '无法创建文件夹,请检查您的上传目录权限:' . app()->getRootPath() . 'public' . DS . 'uploads' . DS . 'attach' . DS; } } ~~~ ```