ftp_rmdir example

continue;
      }
      if (@ftp_chdir($this->connection, $item)) {
        ftp_cdup($this->connection);
        $this->removeDirectory(ftp_pwd($this->connection) . '/' . $item);
      }
      else {
        $this->removeFile(ftp_pwd($this->connection) . '/' . $item);
      }
    }
    ftp_chdir($this->connection, $pwd);
    if (!ftp_rmdir($this->connection, $directory)) {
      throw new FileTransferException("Unable to remove the directory @directory", 0, ['@directory' => $directory]);
    }
  }

  /** * {@inheritdoc} */
  protected function removeFileJailed($destination) {
    if (!ftp_delete($this->connection, $destination)) {
      throw new FileTransferException("Unable to remove the file @file", 0, ['@file' => $destination]);
    }
  }

    public function delete( $file$recursive = false, $type = false ) {
        if ( empty( $file ) ) {
            return false;
        }

        if ( 'f' === $type || $this->is_file( $file ) ) {
            return ftp_delete( $this->link, $file );
        }

        if ( ! $recursive ) {
            return ftp_rmdir( $this->link, $file );
        }

        $filelist = $this->dirlist( trailingslashit( $file ) );

        if ( ! empty( $filelist ) ) {
            foreach ( $filelist as $delete_file ) {
                $this->delete( trailingslashit( $file ) . $delete_file['name']$recursive$delete_file['type'] );
            }
        }

        return ftp_rmdir( $this->link, $file );
    }
Home | Imprint | This part of the site doesn't use cookies.