It will not work if recursion is needed
(I had to remove the watchdog stuff, because if was not able to retrieve the directory listing to do correct tests)
Thanks for the trick anyway ...
function mkdir_ftp($directory) {
global $ftpuser,$ftppass,$ftpmkdir,$ftpdir;
$directory = $ftpdir . $directory;
$ftpConn = ftp_connect($_SERVER['SERVER_NAME']);
if(false == ftp_login($ftpConn,$ftpuser , $ftppass)) {
watchdog('file system',
'The directory cannot be created, ftp_login() failed.',
array(), WATCHDOG_ERROR);
return FALSE;
}
$list=split("/",$directory);
$directory="";$first=true;
foreach($list as $ldir){
if ($first)
$directory.="".$ldir;
else
$directory.="/".$ldir;
$first=false;
ftp_mkdir($ftpConn, $directory));
ftp_chmod($ftpConn, 0777, $directory)
}
ftp_close($ftpConn);
return TRUE;
}
Go trick but ...
It will not work if recursion is needed
(I had to remove the watchdog stuff, because if was not able to retrieve the directory listing to do correct tests)
Thanks for the trick anyway ...
function mkdir_ftp($directory) {
global $ftpuser,$ftppass,$ftpmkdir,$ftpdir;
$directory = $ftpdir . $directory;
$ftpConn = ftp_connect($_SERVER['SERVER_NAME']);
if(false == ftp_login($ftpConn,$ftpuser , $ftppass)) {
watchdog('file system',
'The directory cannot be created, ftp_login() failed.',
array(), WATCHDOG_ERROR);
return FALSE;
}
$list=split("/",$directory);
$directory="";$first=true;
foreach($list as $ldir){
if ($first)
$directory.="".$ldir;
else
$directory.="/".$ldir;
$first=false;
ftp_mkdir($ftpConn, $directory));
ftp_chmod($ftpConn, 0777, $directory)
}
ftp_close($ftpConn);
return TRUE;
}