diff options
author | Phil Sturgeon <email@philsturgeon.co.uk> | 2010-03-12 01:43:28 +0100 |
---|---|---|
committer | Phil Sturgeon <email@philsturgeon.co.uk> | 2010-03-12 01:43:28 +0100 |
commit | 28b293729d2c2917c434c6296eafecd19f397303 (patch) | |
tree | bc3679fcb567ceb3440846056ef9e3fafb6a7cb9 /system/libraries | |
parent | d265871dfe205a905cd6c39e8ac4371f13848e58 (diff) |
Added FTP::download() and the accompanying lang line. This was first proposed in 2007, can we add it now pleeeeease?
Diffstat (limited to 'system/libraries')
-rw-r--r-- | system/libraries/Ftp.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php index 16ad9ad43..07f4b1ff3 100644 --- a/system/libraries/Ftp.php +++ b/system/libraries/Ftp.php @@ -281,6 +281,48 @@ class CI_FTP { // -------------------------------------------------------------------- /** + * Download a file from a remote server to the local server + * + * @access public + * @param string + * @param string + * @param string + * @return bool + */ + function download($rempath, $locpath, $mode = 'auto') + { + if ( ! $this->_is_conn()) + { + return FALSE; + } + + // Set the mode if not specified + if ($mode == 'auto') + { + // Get the file extension so we can set the upload type + $ext = $this->_getext($rempath); + $mode = $this->_settype($ext); + } + + $mode = ($mode == 'ascii') ? FTP_ASCII : FTP_BINARY; + + $result = @ftp_get($this->conn_id, $locpath, $rempath, $mode); + + if ($result === FALSE) + { + if ($this->debug == TRUE) + { + $this->_error('ftp_unable_to_download'); + } + return FALSE; + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** * Rename (or move) a file * * @access public |