\CI_FTP

FTP Class

Summary

Methods
Properties
Constants
__construct()
initialize()
connect()
_login()
_is_conn()
changedir()
mkdir()
upload()
download()
rename()
move()
delete_file()
delete_dir()
chmod()
list_files()
mirror()
_getext()
_settype()
close()
_error()
$hostname
$username
$password
$port
$passive
$debug
$conn_id
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$hostname

$hostname : 

Type

$username

$username : 

Type

$password

$password : 

Type

$port

$port : 

Type

$passive

$passive : 

Type

$debug

$debug : 

Type

$conn_id

$conn_id : 

Type

Methods

__construct()

__construct(  $config = array()) 

Constructor - Sets Preferences

The constructor can be passed an array of config values

Parameters

$config

initialize()

initialize(  $config = array()) : void

Initialize preferences

Parameters

$config

connect()

connect(  $config = array()) : boolean

FTP Connect

Parameters

$config

Returns

boolean

_login()

_login() : boolean

FTP Login

Returns

boolean

_is_conn()

_is_conn() : boolean

Validates the connection ID

Returns

boolean

changedir()

changedir(  $path = '',   $supress_debug = FALSE) : boolean

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.

Parameters

$path
$supress_debug

Returns

boolean

mkdir()

mkdir(  $path = '',   $permissions = NULL) : boolean

Create a directory

Parameters

$path
$permissions

Returns

boolean

upload()

upload(  $locpath,   $rempath,   $mode = 'auto',   $permissions = NULL) : boolean

Upload a file to the server

Parameters

$locpath
$rempath
$mode
$permissions

Returns

boolean

download()

download(  $rempath,   $locpath,   $mode = 'auto') : boolean

Download a file from a remote server to the local server

Parameters

$rempath
$locpath
$mode

Returns

boolean

rename()

rename(  $old_file,   $new_file,   $move = FALSE) : boolean

Rename (or move) a file

Parameters

$old_file
$new_file
$move

Returns

boolean

move()

move(  $old_file,   $new_file) : boolean

Move a file

Parameters

$old_file
$new_file

Returns

boolean

delete_file()

delete_file(  $filepath) : boolean

Rename (or move) a file

Parameters

$filepath

Returns

boolean

delete_dir()

delete_dir(  $filepath) : boolean

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

Parameters

$filepath

Returns

boolean

chmod()

chmod(  $path,   $perm) : boolean

Set file permissions

Parameters

$path
$perm

Returns

boolean

list_files()

list_files(  $path = '.') : array

FTP List files in the specified directory

Parameters

$path

Returns

array

mirror()

mirror(  $locpath,   $rempath) : boolean

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.

Parameters

$locpath
$rempath

Returns

boolean

_getext()

_getext(  $filename) : string

Extract the file extension

Parameters

$filename

Returns

string

_settype()

_settype(  $ext) : string

Set the upload type

Parameters

$ext

Returns

string

close()

close() : boolean

Close the connection

Returns

boolean

_error()

_error(  $line) : boolean

Display error message

Parameters

$line

Returns

boolean