CodeIgniter Forums

Full Version: CI_FTP class - error handling for ftp->connect?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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

El Forum

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

El Forum

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

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

Myles