Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into NEW---FTP-function-mkdir

This commit is contained in:
Anthony Berton
2022-08-05 09:10:45 +02:00
41 changed files with 679 additions and 222 deletions

View File

@@ -218,6 +218,36 @@ function dol_ftp_get($connect_id, $file, $newsection)
}
}
/**
* Upload a FTP file
*
* @param resource $connect_id Connection handler
* @param string $file File name
* @param string $localfile The path to the local file
* @param string $newsection $newsection
* @return result
*/
function dol_ftp_put($connect_id, $file, $localfile, $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_scp_send($connect_id, $localfile, $newremotefileiso, 0644);
} else {
return ftp_put($connect_id, $newremotefileiso, $localfile, FTP_BINARY);
}
}
/**
* Remove FTP directory
*