/** * Remove a directory. * * @see FtpClient::mkdir() * @see FtpClient::cleanDir() * @see FtpClient::remove() * @see FtpClient::delete() * @param string $directory * @param bool $recursive Forces deletion if the directory is not empty * @return bool * @throws FtpException If unable to list the directory to remove */ public function rmdir($directory, $recursive = true) { if ($recursive) { $files = $this->nlist($directory, false, 'rsort'); // remove children foreach ($files as $file) { $this->remove($file, true); } } // remove the directory return $this->ftp->rmdir($directory); }