只有在使用php将文件夹上载到远程ftp后,才能从服务器中删除文件夹
函数ftp\u putAll($conn\u id、$backup、$workpath、$delete){只有在使用php将文件夹上载到远程ftp后,才能从服务器中删除文件夹,php,Php,函数ftp\u putAll($conn\u id、$backup、$workpath、$delete){ $d=dir($backup) 函数deleteAll($backup,$remove=false){ $structure=glob(rtrim($backup,“/”./*”); if(is_数组($structure)){ foreach($file形式的结构){ if(is_dir($file)) deleteAll($file,true); else if(is_file($fi
$d=dir($backup) 函数deleteAll($backup,$remove=false){
$structure=glob(rtrim($backup,“/”./*”);
if(is_数组($structure)){
foreach($file形式的结构){
if(is_dir($file))
deleteAll($file,true);
else if(is_file($file))
取消链接($file);
}
}
如果($remove)
rmdir($backup);
} “test_ftp.php”294L,16785C
while($file = $d->read()) { // do this for each file in the directory
if ($file != "." && $file != "..") { // to prevent an infinite loop
if (is_dir($backup."/".$file)) { // do the following if it is a directory
if (!@ftp_chdir($conn_id, $workpath."/".$file)) {
ftp_mkdir($conn_id, $workpath."/".$file); // create directories that do not yet exist
}
ftp_putAll($conn_id, $backup."/".$file, $workpath."/".$file,$delete); // recursive part
}
else {
$upload = ftp_put($conn_id, $workpath."/".$file, $backup."/".$file, FTP_BINARY,$delete);
// check upload status
if(!$upload){
echo "FTP upload has failed!" ;
}else{
echo "Successfully Uploaded." ;
}
}
}
}
}
ftp_putAll($conn_id, $backup, $workpath,$delete);
// folder path that contains files and subfolders
$path = "/www/calls1";
// call the function
deleteAll($path);