function copyF($dir,$toDir){
foreach (glob($dir."/*") as $val) {
if(is_dir($val)){
copyF($val,$toDir);
}else{
$length=strripos($val,"/");
$shen=substr($val,$length);
$newDir=$toDir.$shen;
copy($val,$newDir);
}
}
}
foreach (glob($dir."/*") as $val) {
if(is_dir($val)){
copyF($val,$toDir);
}else{
$length=strripos($val,"/");
$shen=substr($val,$length);
$newDir=$toDir.$shen;
copy($val,$newDir);
}
}
}