ftp_rawlist return false and I'm not able to say why
This is my code
/**
* Wrapper for ftp_rawlist
*
* @param string $dir
* @param bool $recursive
* @return array an array where each element corresponds to one line of text.
*/
public function rawlist($dir = "/", $recursive = false)
{
if (!$this->_conn) {
throw new \Exception(__CLASS__ . " - no connection established with server");
}
$dir = $this->correctFilePath($dir);
return @ftp_rawlist($this->_conn, $dir, $recursive);
}
dir value is the default one and I don't trigger the no connection exception so I suppose that I'm properly connected.
I'm connecting this way
/**
* Connect to server using connect string
* Connection string: ftp://user:pass@server:port/path
* user,pass,port,path are optional parts
*
* @param string $string
* @param int $timeout
* @return void
* @throws \Exception
*/
public function connect($string, $timeout = 900)
{
$params = $this->validateConnectionString($string);
$port = isset($params['port']) ? (int)$params['port'] : 21;
$this->_conn = ftp_connect($params['host'], $port, $timeout);
if (!$this->_conn) {
throw new \Exception("Cannot connect to host: {$params['host']}");
}
if (isset($params['user']) && isset($params['pass'])) {
$this->login($params['user'], $params['pass']);
} else {
$this->login();
}
if (isset($params['path'])) {
if (!$this->chdir($params['path'])) {
throw new \Exception("Cannot chdir after login to: {$params['path']}");
}
}
}
What am I missing ?