选择语言 :

 Core_Ftp::delete_dir

删除一个目录(包括子目录)

bool Core_Ftp::delete_dir( string $filepath )

参数列表

参数 类型 描述 默认值
$filepath string
返回值
  • bool
File: ./core/classes/ftp.class.php
public function delete_dir($filepath)
{
	if (!$this->_is_conn())
	{
		return false;
	}

	$filepath = preg_replace('/(.+?)\/*$/', '\\1/',  $filepath);

	$list = $this->list_files($filepath);

	if (false!==$list && count($list) > 0)
	{
		foreach ($list as $item)
		{
			if (!@ftp_delete($this->_conn_id, $item))
			{
				$this->delete_dir($item);
			}
		}
	}

	$result = @ftp_rmdir($this->_conn_id, $filepath);

	if (false===$result)
	{
		if (IS_DEBUG)
		{
			Core::debug()->error(__('ftp unable to delete'));
		}
		return false;
	}

	return true;
}