diff --git a/htdocs/core/lib/ftp.lib.php b/htdocs/core/lib/ftp.lib.php
index 3782a170242..d72d98d7f94 100644
--- a/htdocs/core/lib/ftp.lib.php
+++ b/htdocs/core/lib/ftp.lib.php
@@ -89,18 +89,20 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect
}
} else {
if (ftp_login($connect_id, $ftp_user, $ftp_password)) {
- // Turn on passive mode transfers (must be after a successful login
+ // Turn on passive mode transfers (must be after a successful login)
if ($ftp_passive) {
ftp_pasv($connect_id, true);
}
// Change the dir
$newsectioniso = mb_convert_encoding($section, 'ISO-8859-1');
- ftp_chdir($connect_id, $newsectioniso);
+ if (!ftp_chdir($connect_id, $newsectioniso)) {
+ $ok = 0;
+ $mesg = $langs->transnoentitiesnoconv("FailedToChdirOnFTPServer");
+ }
} else {
- $mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials");
$ok = 0;
- $error++;
+ $mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials");
}
}
}
diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang
index a1e25cea1af..32cd6681507 100644
--- a/htdocs/langs/en_US/other.lang
+++ b/htdocs/langs/en_US/other.lang
@@ -327,6 +327,7 @@ SetupOfFTPClientModuleNotComplete=The setup of the FTP or SFTP client module see
FTPFeatureNotSupportedByYourPHP=Your PHP does not support FTP or SFTP functions
FailedToConnectToFTPServer=Failed to connect to server (server %s, port %s)
FailedToConnectToFTPServerWithCredentials=Failed to login to server with defined login/password
+FailedToChdirOnFTPServer=Failed to change directory on the FTP server
FTPFailedToRemoveFile=Failed to remove file %s.
FTPFailedToRemoveDir=Failed to remove directory %s: check permissions and that the directory is empty.
FTPPassiveMode=Passive mode