Discussion:
Testing PHP FTP connection( (if still connected)
Ron Piggott
2014-02-18 03:42:42 UTC
Permalink
Is there a way to test if the FTP connection is still live? Ron

Ron Piggott



www.TheVerseOfTheDay.info
Aziz Saleh
2014-02-18 16:40:43 UTC
Permalink
On Mon, Feb 17, 2014 at 10:42 PM, Ron Piggott <
Post by Ron Piggott
Is there a way to test if the FTP connection is still live? Ron
Ron Piggott
www.TheVerseOfTheDay.info
One way (You can replace your ftp_rawlist with any other file listing
function that returns array):

if (ftp_rawlist($connectionId, '/') === false) { //reconnect}

At first I was going to say to use get_resource_type($connectionId) == 'FTP
Buffer' but then noticed that after the regular FTP timeout, the resource
is still the same. is_resource will still consider the variable a resource
even after a timeout.

Aziz

Loading...