我正在使用 CI FTP 类,带有函数 delete_dir,它应该删除文件夹及其所有内容,但是,如果文件夹中有文件,它不会删除文件夹并输出错误。
功能如下;
function delete_dir($filepath)
{
if ( ! $this->_is_conn())
{
return FALSE;
}
// Add a trailing slash to the file path if needed
$filepath = preg_replace("/(.+?)\/*$/", "\\1/", $filepath);
$list = $this->list_files($filepath);
if ($list !== FALSE AND count($list) > 0)
{
foreach ($list as $item)
{
// If we can't delete the item it's probaly a folder so
// we'll recursively call delete_dir()
if ( ! @ftp_delete($this->conn_id, $item))
{
$this->delete_dir($item);
}
}
}
任何人都知道任何错误?