---
title: "FTP.Client"
description: "FTP client prototype."
canonical_url: "https://www.zeyos.com/zymba/ref/ftp/ftp-client"
markdown_url: "https://www.zeyos.com/ai/guide/zymba/ref/ftp/ftp-client.md"
section: "zymba-reference"
authority: "reference"
language: "en"
source_repository: "https://cloud.zeyos.com/__doc/zymbaref.json"
source_sha256: "05a361c6ddc32e74f4a6dc16fd06f218210ff1b7ce57f26ca1994bfffc407915"
---

# FTP.Client

## FTP.Client

```
object @FTP.Client(@Base) {
	construct(string $server, string $username, string $password, int $timeout) {}
	append(string $path, string $target): $this {}
	close() {}
	countDirectories(string $path): int {}
	countFiles(string $path): int {}
	createDirectory(string $path): $this {}
	delete(string $path): $this {}
	disablePassiveMode(): $this {}
	download(string $path, string $target): $this {}
	echo(string $path): $this {}
	enablePassiveMode(): $this {}
	execute(string $command): object {}
	exists(string $path): bool {}
	exit() {}
	getLastModified(string $path): int {}
	getSize(string $path): int {}
	getWorkingDirectory(): string {}
	isConnected(): bool {}
	isDirectory(string $path): bool {}
	listDirectories(string $path): object {}
	listFiles(string $path): object {}
	move(string $path, string $target): $this {}
	read(string $path, ?int $length, int $position): string {}
	readCSV(string $path, string $delimiter): object {}
	readJSON(string $path): mixed {}
	setPermissions(string $path, int $mode): $this {}
	setTimeout(int $timeout): $this {}
	setWorkingDirectory(string $path): $this {}
	upload(string $path, string $target, int $position): $this {}
	write(string $path, string $string, ?int $length, int $position): int {}
}
```

**FTP client prototype.**

### Prototype

**[Base](#)**

## Methods


### `$this.construct()`


Opens a FTP connection to a specific server and attempts login.

```code
$this.construct(string $server, string $username, string $password, int $timeout): void
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| server | `string`  |  | "" |
| username | `string`  |  | "anonymous" |
| password | `string`  |  | "" |
| timeout | `int`  |  | 60 |




### `$this.append()`


Appends an existing file to a specific target.

```code
$this.append(string $path, string $target): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |
| target | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.close()`


Closes this client and frees its associated resources.

```code
$this.close(): void
```




### `$this.countDirectories()`


Counts the total number of subdirectories in an existing directory.

```code
$this.countDirectories(string $path): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.countFiles()`


Counts the total number of files in an existing directory.

```code
$this.countFiles(string $path): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |




### `$this.createDirectory()`


Creates a directory.

```code
$this.createDirectory(string $path): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.delete()`


Deletes an existing file.

```code
$this.delete(string $path): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.disablePassiveMode()`


Disables passive mode for this client.

```code
$this.disablePassiveMode(): this
```

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.download()`


Downloads an existing file to a specific target.

```code
$this.download(string $path, string $target): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |
| target | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.echo()`


Outputs the content of an existing file.

```code
$this.echo(string $path): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.enablePassiveMode()`


Enables passive mode for this client.

```code
$this.enablePassiveMode(): this
```

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.execute()`


Executes a FTP command and returns its output.

```code
$this.execute(string $command): object
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| command | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `object` | [line, ...] |
| `null` |  |




### `$this.exists()`


Determines whether a path exists.

```code
$this.exists(string $path): bool
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `bool` |  |




### `$this.exit()`


Closes this client and frees its associated resources for the purpose of contextualization.

```code
$this.exit(): void
```




### `$this.getLastModified()`


Gets the timestamp for the last modification date and time of an existing file.

```code
$this.getLastModified(string $path): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |
| `null` |  |




### `$this.getSize()`


Gets the size of an existing file in number of bytes.

```code
$this.getSize(string $path): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |
| `null` |  |




### `$this.getWorkingDirectory()`


Gets the path of the current working directory.

```code
$this.getWorkingDirectory(): string
```

##### Returns

| Type | Value |
| --- | ---  |
| `string` |  |




### `$this.isConnected()`


```code
$this.isConnected(): bool
```

##### Returns

| Type | Value |
| --- | ---  |
| `bool` |  |




### `$this.isDirectory()`


Determines whether a path exists and refers to a directory.

```code
$this.isDirectory(string $path): bool
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `bool` |  |




### `$this.listDirectories()`


```code
$this.listDirectories(string $path): object
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `object` | [filename, ...] |




### `$this.listFiles()`


```code
$this.listFiles(string $path): object
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `object` | [filename, ...] |




### `$this.move()`


Moves an existing file to a specific target.

```code
$this.move(string $path, string $target): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |
| target | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.read()`


Reads the content of an existing file in binary mode up to a specific byte-based length.

```code
$this.read(string $path, ?int $length, int $position): string
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |
| length | `?int`  |  | maximum length |
| position | `int`  |  | 0 |

##### Returns

| Type | Value |
| --- | ---  |
| `string` |  |




### `$this.readCSV()`


```code
$this.readCSV(string $path, string $delimiter): object
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |
| delimiter | `string`  |  | ";" |

##### Returns

| Type | Value |
| --- | ---  |
| `object` | [[value, ...], ...] |




### `$this.readJSON()`


```code
$this.readJSON(string $path): mixed
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `mixed` |  |




### `$this.setPermissions()`


Sets the permissions of an exiting file to a specific numeric mode.

```code
$this.setPermissions(string $path, int $mode): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |
| mode | `int`  |  | 0o777 |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.setTimeout()`


Sets the timeout period of this client to a specific number of seconds.

```code
$this.setTimeout(int $timeout): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| timeout | `int`  |  | 60 |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.setWorkingDirectory()`


Sets the path of the working directory.

```code
$this.setWorkingDirectory(string $path): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.upload()`


Uploads an existing file to a specific target.

```code
$this.upload(string $path, string $target, int $position): this
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |
| target | `string`  |  | "" |
| position | `int`  |  | 0 |

##### Returns

| Type | Value |
| --- | ---  |
| `$this` |  |




### `$this.write()`


Writes a string to a file in binary mode up to a specific byte-based length and returns the number of bytes written.

```code
$this.write(string $path, string $string, ?int $length, int $position): int
```

##### Parameters

| Name | Type | Value | Default |
| --- | --- | --- | --- |
| path | `string`  |  | "" |
| string | `string`  |  | "" |
| length | `?int`  |  | maximum length |
| position | `int`  |  | 0 |

##### Returns

| Type | Value |
| --- | ---  |
| `int` |  |
