diff --git a/htdocs/core/lib/ftp.lib.php b/htdocs/core/lib/ftp.lib.php index 42f5806fba5..52ff8263d07 100644 --- a/htdocs/core/lib/ftp.lib.php +++ b/htdocs/core/lib/ftp.lib.php @@ -246,3 +246,33 @@ function dol_ftp_rmdir($connect_id, $file, $newsection) return @ftp_rmdir($connect_id, $newremotefileiso); } } + + +/** + * Remove FTP directory + * + * @param resource $connect_id Connection handler + * @param string $newdir Dir create + * @param string $newsection $newsection + * @return result + */ +function dol_ftp_mkdir($connect_id, $newdir, $newsection) +{ + + global $conf; + + if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { + $newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169 + } + + // Remote file + $filename = $file; + $remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file; + $newremotefileiso = utf8_decode($remotefile); + + if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) { + return ssh2_sftp_mkdir($connect_id, $newremotefileiso); + } else { + return @ftp_mkdir($connect_id, $newremotefileiso); + } +}