如何检查文件夹是否存在cakephp [英] how to check if folder exists cakephp

查看:174
本文介绍了如何检查文件夹是否存在cakephp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何实例要返回bool?例如$ folder-> exists()=> bool

Is there any instance to return bool? e.g. $folder->exists() => bool

$path = WEBROOT_DIR .'/files/'. $folder_name;
$folder = new Folder('../'.$path); 
//DOESN'T WORK
debug($folder->exists());
//I can do it in this way 
//returns bool
debug(file_exists($folder->path));

我想检查目录是否存在删除它。 但我想使用专门的cake方法检查文件夹是否存在

I want to check if directory exists delete it. but I want to use specifically cake method to check if folder exists

推荐答案

p>

Try this:

$path = 'files' . DS . $folder_name;
$folder = new Folder($path);

if (!is_null($folder->path)) {
    $folder->delete();
}

这篇关于如何检查文件夹是否存在cakephp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆