Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 1 | ######### |
| 2 | FTP Class |
| 3 | ######### |
| 4 | |
| 5 | CodeIgniter's FTP Class permits files to be transfered to a remote |
| 6 | server. Remote files can also be moved, renamed, and deleted. The FTP |
| 7 | class also includes a "mirroring" function that permits an entire local |
| 8 | directory to be recreated remotely via FTP. |
| 9 | |
| 10 | .. note:: SFTP and SSL FTP protocols are not supported, only standard |
| 11 | FTP. |
| 12 | |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 13 | .. contents:: |
| 14 | :local: |
| 15 | |
| 16 | .. raw:: html |
| 17 | |
| 18 | <div class="custom-index container"></div> |
| 19 | |
| 20 | ************************** |
| 21 | Working with the FTP Class |
| 22 | ************************** |
| 23 | |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 24 | Initializing the Class |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 25 | ====================== |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 26 | |
| 27 | Like most other classes in CodeIgniter, the FTP class is initialized in |
| 28 | your controller using the $this->load->library function:: |
| 29 | |
| 30 | $this->load->library('ftp'); |
| 31 | |
| 32 | Once loaded, the FTP object will be available using: $this->ftp |
| 33 | |
| 34 | Usage Examples |
| 35 | ============== |
| 36 | |
| 37 | In this example a connection is opened to the FTP server, and a local |
| 38 | file is read and uploaded in ASCII mode. The file permissions are set to |
vlakoff | a36fd63 | 2012-06-27 02:46:19 +0200 | [diff] [blame] | 39 | 755. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 40 | :: |
| 41 | |
Derek Jones | 5b8ebce | 2011-10-05 16:00:50 -0500 | [diff] [blame] | 42 | $this->load->library('ftp'); |
| 43 | |
| 44 | $config['hostname'] = 'ftp.example.com'; |
| 45 | $config['username'] = 'your-username'; |
| 46 | $config['password'] = 'your-password'; |
| 47 | $config['debug'] = TRUE; |
| 48 | |
| 49 | $this->ftp->connect($config); |
| 50 | |
| 51 | $this->ftp->upload('/local/path/to/myfile.html', '/public_html/myfile.html', 'ascii', 0775); |
| 52 | |
| 53 | $this->ftp->close(); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 54 | |
| 55 | In this example a list of files is retrieved from the server. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 56 | :: |
| 57 | |
Derek Jones | 5b8ebce | 2011-10-05 16:00:50 -0500 | [diff] [blame] | 58 | $this->load->library('ftp'); |
| 59 | |
| 60 | $config['hostname'] = 'ftp.example.com'; |
| 61 | $config['username'] = 'your-username'; |
| 62 | $config['password'] = 'your-password'; |
| 63 | $config['debug'] = TRUE; |
| 64 | |
| 65 | $this->ftp->connect($config); |
| 66 | |
| 67 | $list = $this->ftp->list_files('/public_html/'); |
| 68 | |
| 69 | print_r($list); |
| 70 | |
| 71 | $this->ftp->close(); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 72 | |
| 73 | In this example a local directory is mirrored on the server. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 74 | :: |
| 75 | |
Derek Jones | 5b8ebce | 2011-10-05 16:00:50 -0500 | [diff] [blame] | 76 | $this->load->library('ftp'); |
| 77 | |
| 78 | $config['hostname'] = 'ftp.example.com'; |
| 79 | $config['username'] = 'your-username'; |
| 80 | $config['password'] = 'your-password'; |
| 81 | $config['debug'] = TRUE; |
| 82 | |
| 83 | $this->ftp->connect($config); |
| 84 | |
| 85 | $this->ftp->mirror('/path/to/myfolder/', '/public_html/myfolder/'); |
| 86 | |
| 87 | $this->ftp->close(); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 88 | |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 89 | *************** |
| 90 | Class Reference |
| 91 | *************** |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 92 | |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 93 | .. class:: CI_FTP |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 94 | |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 95 | .. method:: connect([$config = array()]) |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 96 | |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 97 | :param array $config: Connection values |
| 98 | :returns: bool |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 99 | |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 100 | Connects and logs into to the FTP server. Connection preferences are set |
| 101 | by passing an array to the function, or you can store them in a config |
| 102 | file. |
Derek Jones | 5b8ebce | 2011-10-05 16:00:50 -0500 | [diff] [blame] | 103 | |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 104 | Here is an example showing how you set preferences manually:: |
Derek Jones | 5b8ebce | 2011-10-05 16:00:50 -0500 | [diff] [blame] | 105 | |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 106 | $this->load->library('ftp'); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 107 | |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 108 | $config['hostname'] = 'ftp.example.com'; |
| 109 | $config['username'] = 'your-username'; |
| 110 | $config['password'] = 'your-password'; |
| 111 | $config['port'] = 21; |
| 112 | $config['passive'] = FALSE; |
| 113 | $config['debug'] = TRUE; |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 114 | |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 115 | $this->ftp->connect($config); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 116 | |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 117 | **Setting FTP Preferences in a Config File** |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 118 | |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 119 | If you prefer you can store your FTP preferences in a config file. |
| 120 | Simply create a new file called the ftp.php, add the $config array in |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 121 | that file. Then save the file at *application/config/ftp.php* and it |
| 122 | will be used automatically. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 123 | |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 124 | **Available connection options** |
| 125 | |
| 126 | ================== =================================== |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 127 | Option Name Description |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 128 | ================== =================================== |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 129 | **hostname** the FTP hostname. Usually something like: ftp.example.com |
| 130 | **username** the FTP username |
| 131 | **password** the FTP password |
| 132 | **port** The port number. Set to 21 by default. |
| 133 | **debug** TRUE/FALSE (boolean). Whether to enable debugging to display error messages. |
| 134 | **passive** TRUE/FALSE (boolean). Whether to use passive mode. Passive is set automatically by default. |
Derek Jones | b799a0b | 2013-08-06 15:38:21 -0700 | [diff] [blame] | 135 | ================== =================================== |
| 136 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 137 | .. method:: upload($locpath, $rempath[, $mode = 'auto'[, $permissions = NULL]]) |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 138 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 139 | :param string $locpath: Local file path |
| 140 | :param string $rempath: Remote file path |
| 141 | :param string $mode: FTP mode, defaults to 'auto' (options are: 'auto', 'binary', 'ascii') |
| 142 | :param int $permissions: File permissions (octal) |
| 143 | :returns: bool |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 144 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 145 | Uploads a file to your server. You must supply the local path and the |
| 146 | remote path, and you can optionally set the mode and permissions. |
| 147 | Example:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 148 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 149 | $this->ftp->upload('/local/path/to/myfile.html', '/public_html/myfile.html', 'ascii', 0775); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 150 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 151 | If 'auto' mode is used it will base the mode on the file extension of the source file. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 152 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 153 | If set, permissions have to be passed as an octal value. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 154 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 155 | .. method:: download($rempath, $locpath[, $mode = 'auto']) |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 156 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 157 | :param string $rempath: Remote file path |
| 158 | :param string $locpath: Local file path |
| 159 | :param string $mode: FTP mode, defaults to 'auto' (options are: 'auto', 'binary', 'ascii') |
| 160 | :returns: bool |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 161 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 162 | Downloads a file from your server. You must supply the remote path and |
| 163 | the local path, and you can optionally set the mode. Example:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 164 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 165 | $this->ftp->download('/public_html/myfile.html', '/local/path/to/myfile.html', 'ascii'); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 166 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 167 | If 'auto' mode is used it will base the mode on the file extension of the source file. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 168 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 169 | Returns FALSE if the download does not execute successfully (including if PHP does not have permission to write the local file). |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 170 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 171 | .. method:: rename($old_file, $new_file, $move = FALSE) |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 172 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 173 | :param string $old_file: Old file name |
| 174 | :param string $new_file: New file name |
| 175 | :param bool $move: Whether a move is being performed |
| 176 | :returns: bool |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 177 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 178 | Permits you to rename a file. Supply the source file name/path and the new file name/path. |
| 179 | :: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 180 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 181 | // Renames green.html to blue.html |
| 182 | $this->ftp->rename('/public_html/foo/green.html', '/public_html/foo/blue.html'); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 183 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 184 | .. method:: move($old_file, $new_file) |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 185 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 186 | :param string $old_file: Old file name |
| 187 | :param string $new_file: New file name |
| 188 | :returns: bool |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 189 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 190 | Lets you move a file. Supply the source and destination paths:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 191 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 192 | // Moves blog.html from "joe" to "fred" |
| 193 | $this->ftp->move('/public_html/joe/blog.html', '/public_html/fred/blog.html'); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 194 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 195 | .. note:: If the destination file name is different the file will be renamed. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 196 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 197 | .. method:: delete_file($filepath) |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 198 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 199 | :param string $filepath: Path to file to delete |
| 200 | :returns: bool |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 201 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 202 | Lets you delete a file. Supply the source path with the file name. |
| 203 | :: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 204 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 205 | $this->ftp->delete_file('/public_html/joe/blog.html'); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 206 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 207 | .. method:: delete_dir($filepath) |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 208 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 209 | :param string $filepath: Path to directory to delete |
| 210 | :returns: bool |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 211 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 212 | Lets you delete a directory and everything it contains. Supply the |
| 213 | source path to the directory with a trailing slash. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 214 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 215 | .. important:: Be VERY careful with this method! |
| 216 | It will recursively delete **everything** within the supplied path, |
| 217 | including sub-folders and all files. Make absolutely sure your path |
| 218 | is correct. Try using ``list_files()`` first to verify that your path is correct. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 219 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 220 | :: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 221 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 222 | $this->ftp->delete_dir('/public_html/path/to/folder/'); |
Derek Jones | 5b8ebce | 2011-10-05 16:00:50 -0500 | [diff] [blame] | 223 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 224 | .. method:: list_files([$path = '.']) |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 225 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 226 | :param string $path: Directory path |
| 227 | :returns: array or FALSE on failure |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 228 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 229 | Permits you to retrieve a list of files on your server returned as an |
| 230 | array. You must supply the path to the desired directory. |
| 231 | :: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 232 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 233 | $list = $this->ftp->list_files('/public_html/'); |
| 234 | print_r($list); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 235 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 236 | .. method:: mirror($locpath, $rempath) |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 237 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 238 | :param string $locpath: Local path |
| 239 | :param string $rempath: Remote path |
| 240 | :returns: bool |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 241 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 242 | Recursively reads a local folder and everything it contains (including |
| 243 | sub-folders) and creates a mirror via FTP based on it. Whatever the |
| 244 | directory structure of the original file path will be recreated on the |
| 245 | server. You must supply a source path and a destination path:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 246 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 247 | $this->ftp->mirror('/path/to/myfolder/', '/public_html/myfolder/'); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 248 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 249 | .. method:: mkdir($path[, $permissions = NULL]) |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 250 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 251 | :param string $path: Path to directory to create |
| 252 | :param int $permissions: Permissions (octal) |
| 253 | :returns: bool |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 254 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 255 | Lets you create a directory on your server. Supply the path ending in |
| 256 | the folder name you wish to create, with a trailing slash. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 257 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 258 | Permissions can be set by passing an octal value in the second parameter. |
| 259 | :: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 260 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 261 | // Creates a folder named "bar" |
| 262 | $this->ftp->mkdir('/public_html/foo/bar/', DIR_WRITE_MODE); |
| 263 | |
| 264 | .. method:: chmod($path, $perm) |
| 265 | |
| 266 | :param string $path: Path to alter permissions for |
| 267 | :param int $perm: Permissions (octal) |
| 268 | :returns: bool |
| 269 | |
| 270 | Permits you to set file permissions. Supply the path to the file or |
| 271 | directory you wish to alter permissions on:: |
| 272 | |
| 273 | // Chmod "bar" to 777 |
| 274 | $this->ftp->chmod('/public_html/foo/bar/', DIR_WRITE_MODE); |
| 275 | |
Andrey Andreev | a322989 | 2014-01-03 17:35:52 +0200 | [diff] [blame^] | 276 | .. method:: changedir($path[, $suppress_debug = FALSE]) |
| 277 | |
| 278 | :param string $path: Directory path |
| 279 | :param bool $suppress_debug: Whether to turn off debug messages for this command |
| 280 | :returns: bool |
| 281 | |
| 282 | Changes the current working directory to the specified path. |
| 283 | |
| 284 | The ``$suppress_debug`` parameter is useful in case you want to use this method |
| 285 | as an ``is_dir()`` alternative for FTP. |
| 286 | |
Andrey Andreev | eb21ac8 | 2014-01-03 17:27:29 +0200 | [diff] [blame] | 287 | .. method:: close() |
| 288 | |
| 289 | :returns: bool |
| 290 | |
| 291 | Closes the connection to your server. It's recommended that you use this |
| 292 | when you are finished uploading. |