Skip to content
Mathieu Nayrolles edited this page Jan 20, 2016 · 1 revision

CI_FTP

FTP Class

  • Class name: CI_FTP
  • Namespace:

Properties

$hostname

public string $hostname = ''

FTP Server hostname

  • Visibility: public

$username

public string $username = ''

FTP Username

  • Visibility: public

$password

public string $password = ''

FTP Password

  • Visibility: public

$port

public integer $port = 21

FTP Server port

  • Visibility: public

$passive

public boolean $passive = TRUE

Passive mode flag

  • Visibility: public

$debug

public boolean $debug = FALSE

Debug flag

Specifies whether to display error messages.

  • Visibility: public

$conn_id

protected resource $conn_id

Connection ID

  • Visibility: protected

Methods

__construct

void CI_FTP::__construct(array $config)

Constructor

  • Visibility: public

Arguments

  • $config array

initialize

void CI_FTP::initialize(array $config)

Initialize preferences

  • Visibility: public

Arguments

  • $config array

connect

boolean CI_FTP::connect(array $config)

FTP Connect

  • Visibility: public

Arguments

  • $config array - <p>Connection values</p>

_login

boolean CI_FTP::_login()

FTP Login

  • Visibility: protected

_is_conn

boolean CI_FTP::_is_conn()

Validates the connection ID

  • Visibility: protected

changedir

boolean CI_FTP::changedir(string $path, boolean $suppress_debug)

Change directory

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.

  • Visibility: public

Arguments

  • $path string
  • $suppress_debug boolean

mkdir

boolean CI_FTP::mkdir(string $path, integer $permissions)

Create a directory

  • Visibility: public

Arguments

  • $path string
  • $permissions integer

upload

boolean CI_FTP::upload(string $locpath, string $rempath, string $mode, integer $permissions)

Upload a file to the server

  • Visibility: public

Arguments

  • $locpath string
  • $rempath string
  • $mode string
  • $permissions integer

download

boolean CI_FTP::download(string $rempath, string $locpath, string $mode)

Download a file from a remote server to the local server

  • Visibility: public

Arguments

  • $rempath string
  • $locpath string
  • $mode string

rename

boolean CI_FTP::rename(string $old_file, string $new_file, boolean $move)

Rename (or move) a file

  • Visibility: public

Arguments

  • $old_file string
  • $new_file string
  • $move boolean

move

boolean CI_FTP::move(string $old_file, string $new_file)

Move a file

  • Visibility: public

Arguments

  • $old_file string
  • $new_file string

delete_file

boolean CI_FTP::delete_file(string $filepath)

Rename (or move) a file

  • Visibility: public

Arguments

  • $filepath string

delete_dir

boolean CI_FTP::delete_dir(string $filepath)

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

  • Visibility: public

Arguments

  • $filepath string

chmod

boolean CI_FTP::chmod(string $path, integer $perm)

Set file permissions

  • Visibility: public

Arguments

  • $path string - <p>File path</p>
  • $perm integer - <p>Permissions</p>

list_files

array CI_FTP::list_files(string $path)

FTP List files in the specified directory

  • Visibility: public

Arguments

  • $path string

mirror

boolean CI_FTP::mirror(string $locpath, string $rempath)

Read a directory and recreate it remotely

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.

  • Visibility: public

Arguments

  • $locpath string - <p>Path to source with trailing slash</p>
  • $rempath string - <p>Path to destination - include the base folder with trailing slash</p>

_getext

string CI_FTP::_getext(string $filename)

Extract the file extension

  • Visibility: protected

Arguments

  • $filename string

_settype

string CI_FTP::_settype(string $ext)

Set the upload type

  • Visibility: protected

Arguments

  • $ext string - <p>Filename extension</p>

close

boolean CI_FTP::close()

Close the connection

  • Visibility: public

_error

void CI_FTP::_error(string $line)

Display error message

  • Visibility: protected

Arguments

  • $line string
Clone this wiki locally