FTP Class

package Fuel
category Core
author Phil Sturgeon
link http://docs.fuelphp.com/classes/ftp.html

 Methods

Sets the initial Ftp filename and local data.

__construct(string | array $config) 

Parameters

$config

stringarray

The name of the config group to use, or a configuration array.

Close the connection when the class is unset

__destruct() : void

Change directory

change_dir(string $path) : bool

The second parameter lets us momentarily turn off debugging so that this function can be used to test for the existence of a folder without throwing an error. There's no FTP equivalent to is_dir() so we do it by trying to change to a particular directory. Internally, this parameter is only used by the "mirror" function below.

Parameters

$path

string

Exceptions

\FtpFileAccessException

Returns

bool

Set file permissions

chmod(string $path, string $permissions) : bool

Parameters

$path

string

the file path

$permissions

string

the permissions

Exceptions

\FtpFileAccessException

Returns

bool

Close the connection

close() : void

FTP Connect

connect() : \Ftp

Exceptions

\FtpConnectionException

Returns

\Ftp

Delete a folder and recursively delete everything (including sub-folders) contained within it.

delete_dir(string $filepath) : bool

Parameters

$filepath

string

Exceptions

\FtpFileAccessException

Returns

bool

Rename (or move) a file

delete_file(string $filepath) : bool

Parameters

$filepath

string

Exceptions

\FtpFileAccessException

Returns

bool

Download a file from a remote server to the local server

download(string $remote_path, string $local_path, string $mode) : bool

Parameters

$remote_path

string

$local_path

string

$mode

string

Exceptions

\FtpFileAccessException

Returns

bool

Returns a new Ftp object.

forge(string | array $config, bool $connect) : \Fuel\Core\Ftp

If you do not define the "file" parameter,

$ftp = static::forge('group');

Parameters

$config

stringarray

The name of the config group to use, or a configuration array.

$connect

bool

Automatically connect to this server.

Returns

FTP List files in the specified directory

list_files(string $path) : array

Parameters

$path

string

Returns

array

Read a directory and recreate it remotely

mirror(string $local_path, string $remote_path) : bool

This function recursively reads a folder and everything it contains (including sub-folders) and creates a mirror via FTP based on it. Whatever the directory structure of the original file path will be recreated on the server.

Parameters

$local_path

string

path to source with trailing slash

$remote_path

string

path to destination - include the base folder with trailing slash

Returns

bool

Create a directory

mkdir(string $path, string $permissions) : bool

Parameters

$path

string

$permissions

string

Exceptions

\FtpFileAccessException

Returns

bool

Move a file

move(string $old_file, string $new_file) : bool

Parameters

$old_file

string

$new_file

string

Returns

bool

Rename (or move) a file

rename(\Fuel\Core\$old_file $old_file, \Fuel\Core\$new_file $new_file, \Fuel\Core\$move $move) : bool

Parameters

$old_file

\Fuel\Core\$old_file

string

$new_file

\Fuel\Core\$new_file

string

$move

\Fuel\Core\$move

bool

Exceptions

\FtpFileAccessException

Returns

bool

Upload a file to the server

upload(string $local_path, string $remote_path, string $mode, string $permissions) : bool

Parameters

$local_path

string

$remote_path

string

$mode

string

$permissions

string

Exceptions

\FtpFileAccessException

Returns

bool

Validates the connection ID

_is_conn() : bool

Returns

bool

Set the upload type

_settype(string $ext) : string

Parameters

$ext

string

Returns

string

 Properties

 

$initialized

$initialized 

 

$_conn_id

$_conn_id 

 

$_debug

$_debug 

 

$_hostname

$_hostname 

 

$_passive

$_passive 

 

$_password

$_password 

 

$_port

$_port 

 

$_timeout

$_timeout 

 

$_username

$_username