I try to move all files from SFTP folder to a local folder.
I use the following script:
$connection = ssh2_connect('x.x.x.x', 22);
if (!ssh2_auth_password($connection, 'User_login', 'User_Pass')) {
throw new Exception('Impossible de ce connencter.');
}
if (!$sftp = ssh2_sftp($connection)) {
throw new Exception('Impossible de ce connencter.');
}
$files = array();
$dirHandle = opendir("ssh2.sftp://$sftp/01_Folder/");
while (false !== ($file = readdir($dirHandle))) {
if ($file != '.' && $file != '..') {
$files[] = $file;
}
}
Thanks Guys.