CodeIgniter Forums
FTP/SFTP in CodeIgniter - 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: FTP/SFTP in CodeIgniter (/showthread.php?tid=49343)



FTP/SFTP in CodeIgniter - El Forum - 02-16-2012

[eluser]dailygrind[/eluser]
Hi,
I'm developing an application that will need to transfer files. I don't know at the moment if will be an FTP or a SFTP protocol. How do you think I should design it using CodeIgniter? Is there an SFTP class in CI?


FTP/SFTP in CodeIgniter - El Forum - 02-16-2012

[eluser]Mauricio de Abreu Antunes[/eluser]
No, CI has no SFTP implementation.
https://github.com/ipolar/CodeIgniter-sFTP-Library


Look his lib and create your own. Smile
I can help you if you need, i would be glad to help.


FTP/SFTP in CodeIgniter - El Forum - 02-16-2012

[eluser]dailygrind[/eluser]
Hi thanks!
My idea was to develop a wrapper class so that I can use it in this sort of way but having of course both FTP and SFTP implementation behind it.

Code:
$transfer = new Transfer();
$transfer->connect();
$transfer->upload('/local/this.txt', '/remote/this.txt');
$transfer->close();

My idea was to name methods like this

Code:
private function _ftp_connect()
private function _sftp_connect()

and call them based on a config file using __call....

Is this a good approach?


FTP/SFTP in CodeIgniter - El Forum - 02-16-2012

[eluser]Mauricio de Abreu Antunes[/eluser]
My idea:
1 - Watch for the difference between STFP and FTP.
2 - Try to construct a lib with a parent class, reusing common methods (SFTP and FTP).

Good luck and have fun!



FTP/SFTP in CodeIgniter - El Forum - 02-16-2012

[eluser]dailygrind[/eluser]
Thanks for the tip! Will do.


FTP/SFTP in CodeIgniter - El Forum - 02-16-2012

[eluser]PhilTem[/eluser]
You might also wanna have a look at CI-Drivers. That's probably better fitting your needs. And in terms of the idea of drivers and libraries, a driver fits much better Wink


FTP/SFTP in CodeIgniter - El Forum - 02-16-2012

[eluser]InsiteFX[/eluser]
This would be just right for creating a CI Driver class.

CodeIgniter User Guide - Using CodeIgniter Drivers

CodeIgniter User Guide - Creating Drivers



FTP/SFTP in CodeIgniter - El Forum - 02-16-2012

[eluser]InsiteFX[/eluser]
LOL @PhilTem lookat post times...



FTP/SFTP in CodeIgniter - El Forum - 02-16-2012

[eluser]Mauricio de Abreu Antunes[/eluser]
@PhilTem and @InsiteFX

Are you brothers? HAHA!

Anyway, tell me: why is CI Driver better than CI Lib?