//用法:
//Copy_folder("源目录","目标目录",1):拷贝“源目录”下的文件到“目标目录”,包括子目录
//Copy_folder("源目录","目标目录",0):拷贝“源目录”下的文件到“目标目录”,不包括子目录
function Copy_folder($source, $destination, $child){
if(!is_dir($source)){
echo("Source Error!");
return 0;
}
if(!is_dir($destination)){
mkdir($destination,0777);
}
$handle=dir($source);
while($entry=$handle->read()){
if(($entry!=".")&&($entry!="..")){
if(is_dir($source."/".$entry)){
if($child) Copy_folder($source."/".$entry,$destination."/".$entry,$child);
}else{
if ( ! file_exists($destination."/".$entry) ) copy($source."/".$entry,$destination."/".$entry);
}
}
}
return 1;
}
//Copy_folder("源目录","目标目录",1):拷贝“源目录”下的文件到“目标目录”,包括子目录
//Copy_folder("源目录","目标目录",0):拷贝“源目录”下的文件到“目标目录”,不包括子目录
function Copy_folder($source, $destination, $child){
if(!is_dir($source)){
echo("Source Error!");
return 0;
}
if(!is_dir($destination)){
mkdir($destination,0777);
}
$handle=dir($source);
while($entry=$handle->read()){
if(($entry!=".")&&($entry!="..")){
if(is_dir($source."/".$entry)){
if($child) Copy_folder($source."/".$entry,$destination."/".$entry,$child);
}else{
if ( ! file_exists($destination."/".$entry) ) copy($source."/".$entry,$destination."/".$entry);
}
}
}
return 1;
}