diff options
-rw-r--r-- | system/language/english/ftp_lang.php | 1 | ||||
-rw-r--r-- | system/libraries/Ftp.php | 42 |
2 files changed, 43 insertions, 0 deletions
diff --git a/system/language/english/ftp_lang.php b/system/language/english/ftp_lang.php index 42403b971..392b2b272 100644 --- a/system/language/english/ftp_lang.php +++ b/system/language/english/ftp_lang.php @@ -7,6 +7,7 @@ $lang['ftp_unable_to_makdir'] = "Unable to create the directory you have specif $lang['ftp_unable_to_changedir'] = "Unable to change directories."; $lang['ftp_unable_to_chmod'] = "Unable to set file permissions. Please check your path. Note: This feature is only available in PHP 5 or higher."; $lang['ftp_unable_to_upload'] = "Unable to upload the specified file. Please check your path."; +$lang['ftp_unable_to_download'] = "Unable to download the specified file. Please check your path."; $lang['ftp_no_source_file'] = "Unable to locate the source file. Please check your path."; $lang['ftp_unable_to_rename'] = "Unable to rename the file."; $lang['ftp_unable_to_delete'] = "Unable to delete the file."; 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 |