FTP class

The following sections explain each method of the class.

connect


public void connect ( string $host, boolean $ssl = false, integer $port = 21, integer $timeout = 90)

Opens an FTP / SSL FTP connection to the target server.

Parameter list
host

The host address of the destination FTP server.

ssl

If a SSL FTP connection should be established, the parameters can here ssl to the value true to be set. By default, on false

port

The port on which the FTP connection can be established. By default, the value 21

timeout

Should be canceled Specifies how many seconds the attempt to connect.


login


public void login ( string $username, string $password)

Logs in using the access in the pre-built FTP / SSL FTP connection.

Parameter list
username

The username to log in to the open FTP / SSL FTP connection to register.

password

The password for the corresponding user name to log in the open FTP / SSL FTP connection.


set_passive_modus


public void set_passive_modus ( )

Sets the open FTP / SSL FTP connection in Passive mode.


get_remote_file


public bool get_remote_file ( string $remoteFile, string $localeFile)

Downloads a file from the FTP server to the local server.

Parameter list
remoteFile

The absolute path to the FTP server file. Only files can be downloaded. Folders are not allowed.

localeFile

The absolute path to the local file. This is not enough if only the directory is specified. The filename of the file to be created must be reported.


modified_time


public int|string|bool modified_time ( string $remoteFile, mixed $timeFormat = null)

Specifies the UNIX last modified time stamp or date formatted time specifying the FTP server returns file.

Parameter list
remoteFile

The absolute path to the FTP server file. Here also folders can be selected.

timeFormat

Here you can decide whether you want to last modified as a UNIX timestamp or returned as formatted date. When set to null is set, the UNIX timestamp is returned. Otherwise, the formatted date. Default to null set.


up


public bool up ( )

Rises in the open FTP connection a directory further upwards, as far as possible.


is_dir


public bool is_dir ( string $remoteFile = '.')

Checks whether the specified absolute FTP server path is a directory.

Parameter list
remoteFile

The absolute FTP server path to be checked whether it is a directory. By default on. set.


count


public int count ( string $remoteDirectory = '.', string $type = null, bool $recursive = true)

Counts the contents of an FTP server directory and returns the number of elements found back.

Parameter list
remoteDirectory

The absolute path to the FTP server directory whose contents are to be counted.

type

Here you can decide what should be considered a type of counting. You can choose between file , directory , link or null select. At null , the entire contents of which are counted. Default to null

recursive

Here you can decide whether the contents of subdirectories to be counted. Default to true set.


is_empty


public bool is_empty ( string $remoteDirectory)

Controls whether a FTP server directory is empty.

Parameter list
remoteDirectory

The absolute path to the FTP server directory.


put_from_path


public bool put_from_path ( string $local_file)

Loading a local file on the FTP server.

Parameter list
locale_file

The absolute path to the local file to be uploaded to the FTP server. They Loading connection to the current directory of open FTP / SSL FTP.


put_all


public bool put_all ( string $source_directory, string $target_directory, int $mode = FTP_BINARY)

Loading an entire directory and its contents recursively into FTP server directory.

Parameter list
source_directory

The local absolute path to the file to be uploaded to the FTP server.

target_directory

The absolute path to the FTP server destination directory in which the data is to be uploaded.

mode

The FTP data transfer mode. The following are available:

  • FTP_ASCII
  • FTP_TEXT
  • FTP_BINARY
  • FTP_IMAGE


put_from_string


public bool put_from_string ( string $remote_file, $content)

Loads the contents of a variable in an FTP server file.

Parameter list
remote_file

The absolute path to the FTP server file.

content

The content to be written in the FTP server file.


dir_size


public int dir_size ( string $remoteDirectory = '.', bool $recursive = true)

Specifies the folder size of an FTP server returns directory.

Parameter list
remoteDirectory

The absolute path to the FTP server directory.

recursive

Whether subdirectory sizes should be factored in to the folder size. Default to true


nlist


public array nlist ( string $remoteDirectory = '.', boolean $recursive = false, string $filter = 'sort')

Lists the contents of an FTP server directory. Also recursively possible.

Parameter list
remoteDirectory

The absolute path to the FTP server directory whose contents are to be counted.

recursive

Whether subdirectories from the FTP server directory with should be included. Default to true

filter

Filters the result with a predefined PHP function. By default, the PHP function sort()


mkdir


public bool nlist ( string $remoteDirectory, $recursive = false)

Created on the FTP server directory. Also recursively possible.

Parameter list
remoteDirectory

The absolute path to the FTP server directory whose contents are to be counted.

recursive

Whether the FTP server path to be applied recursively. Default to true


remove


public bool remove ( string $remoteFile)

Loading a local file on the FTP server.

Parameter list
remoteFile

The absolute path to the FTP server file to be deleted.


rmdir


public bool rmdir ( string $remoteDirectory, bool $recursive = false)

Deletes an FTP server directory and its contents. Also recursively possible.

Parameter list
remoteDirectory

The absolute FTP server path to the directory to be deleted.

recursive

Whether the FTP server directory to be deleted recursively. Default to true set.


clean_dir


public bool clean_dir ( string $remoteDirectory)

Cleans a complete FTP directory recursively.

Parameter list
remoteDirectory

The absolute path to the FTP server directory to be emptied.


scan_dir


public array scan_dir ( string $remoteDirectory = '.', $recursive = false)

Scans an FTP directory, recursively, and provides all the files and directories found back.

Parameter list
remoteDirectory

The absolute path to the FTP directory to be scanned.

recursive

Whether subfolders should be included in the scan.


rawlist


public array rawlist ( string $remoteDirectory = '.', $recursive = false)

Includes the same function as the method scan_dir only this method still return more detailed information about the file.

Parameter list
remoteDirectory

The absolute path to the FTP directory to be scanned.

recursive

Whether subfolders should be included in the scan.