越简单越好!

php移动文件夹

发表于 2007-03-07 17:43 | 1221次阅读 0次点赞   PHP
function move_d($source,$target){
 $dest_name=basename($source); 
 if(is_dir($source)){                 
  if(!mkdir($target.$dest_name)){
   return false;                  
  }                  
  $d=dir($source);
  while(($entry=$d->read())!==false){
   if(is_dir($source.$entry)){
    if($entry=="."||$entry==".."){
     continue; 
    }else{
     move_d("$source$entry/","$target$dest_name/");
    }                          
   }else{
    if(!copy("$source$entry","$target$dest_name/$entry")){
     return false;
    }
   }
  } 
 }else{ 
  if(!copy("$source$entry","$target$dest_name/")){ 
   return false;
  } 
 }
return true;
}
返回顶部 ^