CodeIgniter Forums
CI_FTP class - error handling for ftp->connect? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: CI_FTP class - error handling for ftp->connect? (/thread-16090.html)



CI_FTP class - error handling for ftp->connect? - El Forum - 02-24-2009

[eluser]Myles Wakeham[/eluser]
Looking for some 'best practices' on this. I have to connect to a dozen different servers in a round-robin arrangement, copying files to each via FTP. I need a way to ensure that ftp->connect doesn't fail, and if it does handle it gracefully.

Other than reading debug messages (which won't work for me since a human won't be doing this), is there any return value that can be tested for ftp->connect or some other way to test if the connection succeeded?

Thanks
Myles


CI_FTP class - error handling for ftp->connect? - El Forum - 02-24-2009

[eluser]TheFuzzy0ne[/eluser]
It really is as simple as you might expect it to be.
Code:
if ($this->ftp->connect())
{
    // Woohoo!
}
else
{
    // D'oh!!
}



CI_FTP class - error handling for ftp->connect? - El Forum - 02-24-2009

[eluser]Myles Wakeham[/eluser]
I was hoping for an answer like that! Smile

Thanks. Next time I'll check the source on it.

Myles