无限级目录与目录之间的复制代码_PHP教程

WBOY
發布: 2016-07-13 17:09:08
原創
1064 人瀏覽過

无限级目录复制,站长原创,虽只写了短短几分钟,但还是挺有用的


$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"复制完毕";
}

?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/629774.htmlTechArticle无限级目录复制,站长原创,虽只写了短短几分钟,但还是挺有用的 ? $o_path=admin;//源目录 $n_path=n_admin;//新目录 class copy_path { function wm_chi...
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!