无限级目录复制

无限级目录复制,

<?
//本程序由wm_chief原创,如要转载,请注明作者与来源(http://www.phome.net)
$o_path="admin";//源目录
$n_path="n_admin";//新目录
class  copy_path
{
function  wm_chief_copypath($o_path,$n_path)
{$hand=opendir($o_path);
if(!file_exists($n_path))//目标目录不存在则建立
{$this->wm_chief_createpath($n_path);}
$i=0;
while($file=readdir($hand))
{$i++;
if($i==1||$i==2)
{continue;}
if(!(strchr($file,".")))
{
$o_s_path=$o_path."/".$file;
$n_s_path=$n_path."/".$file;
$this->wm_chief_copypath($o_s_path,$n_s_path);
}
else
{
$o_file=$o_path."/".$file;
$n_file=$n_path."/".$file;
$this->wm_chief_copyfile($o_file,$n_file);
}
}
closedir($hand);
return  true;
}
function  wm_chief_copyfile($o_file,$n_file)
{
copy($o_file,$n_file);
}
function  wm_chief_createpath($n_path)
{
mkdir($n_path,0777);
}
}
$wm_chief=new  copy_path();
$wm_chief_ok=$wm_chief->wm_chief_copypath($o_path,$n_path);
if($wm_chief_ok)
{
echo"复制完毕";
}
//本程序由wm_chief原创,如要转载,请注明作者与来源(http://www.phome.net)
?>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值