My Project
 All Data Structures Namespaces Functions Variables
Public Member Functions | Data Fields
CI_FTP Class Reference

Public Member Functions

 __construct ($config=array())
 
 initialize ($config=array())
 
 connect ($config=array())
 
 _login ()
 
 _is_conn ()
 
 changedir ($path= '', $supress_debug=FALSE)
 
 mkdir ($path= '', $permissions=NULL)
 
 upload ($locpath, $rempath, $mode= 'auto', $permissions=NULL)
 
 download ($rempath, $locpath, $mode= 'auto')
 
 rename ($old_file, $new_file, $move=FALSE)
 
 move ($old_file, $new_file)
 
 delete_file ($filepath)
 
 delete_dir ($filepath)
 
 chmod ($path, $perm)
 
 list_files ($path= '.')
 
 mirror ($locpath, $rempath)
 
 _getext ($filename)
 
 _settype ($ext)
 
 close ()
 
 _error ($line)
 

Data Fields

 $hostname = ''
 
 $username = ''
 
 $password = ''
 
 $port = 21
 
 $passive = TRUE
 
 $debug = FALSE
 
 $conn_id = FALSE
 

Constructor & Destructor Documentation

__construct (   $config = array())

Constructor - Sets Preferences

The constructor can be passed an array of config values

Member Function Documentation

_error (   $line)

Display error message

private

Parameters
string
Returns
bool
_getext (   $filename)

Extract the file extension

private

Parameters
string
Returns
string
_is_conn ( )

Validates the connection ID

private

Returns
bool
_login ( )

FTP Login

private

Returns
bool
_settype (   $ext)

Set the upload type

private

Parameters
string
Returns
string
changedir (   $path = '',
  $supress_debug = FALSE 
)

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.

public

Parameters
string
bool
Returns
bool
chmod (   $path,
  $perm 
)

Set file permissions

public

Parameters
stringthe file path
stringthe permissions
Returns
bool
close ( )

Close the connection

public

Parameters
stringpath to source
stringpath to destination
Returns
bool
connect (   $config = array())

FTP Connect

public

Parameters
arraythe connection values
Returns
bool
delete_dir (   $filepath)

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

public

Parameters
string
Returns
bool
delete_file (   $filepath)

Rename (or move) a file

public

Parameters
string
Returns
bool
download (   $rempath,
  $locpath,
  $mode = 'auto' 
)

Download a file from a remote server to the local server

public

Parameters
string
string
string
Returns
bool
initialize (   $config = array())

Initialize preferences

public

Parameters
array
Returns
void
list_files (   $path = '.')

FTP List files in the specified directory

public

Returns
array
mirror (   $locpath,
  $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.

public

Parameters
stringpath to source with trailing slash
stringpath to destination - include the base folder with trailing slash
Returns
bool
mkdir (   $path = '',
  $permissions = NULL 
)

Create a directory

public

Parameters
string
Returns
bool
move (   $old_file,
  $new_file 
)

Move a file

public

Parameters
string
string
Returns
bool
rename (   $old_file,
  $new_file,
  $move = FALSE 
)

Rename (or move) a file

public

Parameters
string
string
bool
Returns
bool
upload (   $locpath,
  $rempath,
  $mode = 'auto',
  $permissions = NULL 
)

Upload a file to the server

public

Parameters
string
string
string
Returns
bool

The documentation for this class was generated from the following file: