开发文档 v2.x

文件夹操作

更新时间:2024年4月3日 16:53 浏览:313

 

createDir - 文件夹 - 创建

public function createDir(string $dirPath): string

参数:

  • string $dirPath - 文件夹路径 以 '/' 开头,以 '/' 结尾

返回值:

  • string - 创建成功的文件的网址

 

代码示例:

$url = Be::getStorage()->createDir('/abc/def/');
// 返回网址
// https://cdn.phpbe.com/abc/def/

 

deleteDir - 文件夹 - 删除

public function deleteDir(string $dirPath): bool

参数:

  • string $dirPath - 文件夹路径 以 '/' 开头,以 '/' 结尾

返回值:

  • bool - 是否删除成功

 

代码示例:

Be::getStorage()->deleteDir('/abc/def/');

 

renameDir - 文件夹 - 重命名

public function renameDir(string $oldDirPath, string $newDirPath): string

参数:

  • string $oldDirPath - 旧文件夹路径 以 '/' 开头,以 '/' 结尾
  • string $newDirPath - 新文件夹路径 以 '/' 开头,以 '/' 结尾

返回值:

  • string - 重命名成功的新文件夹的网址

 

代码示例:

$oldDirPath = '/abc/';
$newDirPath = '/def/';
$url = Be::getStorage()->renameDir($oldDirPath, $newDirPath);

 

isDirExist - 文件夹是否存在

public function isDirExist(string $dirPath): bool

 参数:

  • string $dirPath - 文件夹路径 以 '/' 开头,以 '/' 结尾

返回值:

  • bool - 是否存在

 

代码示例:

$dirPath = '/def/';
if (Be::getStorage()->isDirExist($dirPath)) {
  // ...
}

 

 

 

导航