Improved FTP Class - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Improved FTP Class (/showthread.php?tid=2311) |
Improved FTP Class - El Forum - 07-29-2007 [eluser]Phil Sturgeon[/eluser] I recently made a class takes config "groups" just like the database config. I used this as I wanted to be able to connect to various different servers within the same file without having to enter the config arrays many times. /application/config/Ftp.php Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); /application/libraries/MY_Ftp.php Code on Pastebin for now The benefits of this are that it can be used EXACTLY like the old FTP library, with some added usefulness with the multiple connection types, and obviously saves on repeated code. You can pass it custom config variables, or simply the name of one of your groups like so: Code: $this->ftp->connect('media_server'); $this->ftp->move('public_html/local/file.png', 'public_html/remote/file.png'); It also supports FTP SSL connections. For error messages to be able to show, you will need to add the line below to your ftp lang file. Code: // Custom Please test it and let me know how it goes. If it works ok then i'll put it on the Wiki. Improved FTP Class - El Forum - 07-29-2007 [eluser]coolfactor[/eluser] Thanks for your contributions. However, if you're going to "improve" a built-in class, it is best to extend the class rather than replace it outright. Code: class MY_FTP extends CI_FTP { and then put all of your modifications into MY_FTP class. Improved FTP Class - El Forum - 07-30-2007 [eluser]Phil Sturgeon[/eluser] Indeed! Updated origional post to show the extention instead, with a bugfix. Improved FTP Class - El Forum - 08-04-2007 [eluser]Phil Sturgeon[/eluser] Updated the link to a new version which contains FTP Download functionality. Improved FTP Class - El Forum - 10-10-2008 [eluser]eger[/eluser] I wanted to say thanks for the download function in this extended class. I think the original CI FTP class should include the download function. I was puzzled to find no way to download files. I was able to extend the original class and add your download function and it works just fine. Improved FTP Class - El Forum - 01-08-2009 [eluser]Phil Sturgeon[/eluser] Ignore this post, replied to the wrong FTP related thread. |