Home > php教程 > php手册 > PHP 文件或文件夹拷本

PHP 文件或文件夹拷本

WBOY
Release: 2016-06-21 09:06:27
Original
1075 people have browsed it

function copyFPHP($f){
 $files=explode("|||",$f);
 if(is_dir($files[0])){
  if(copydir($files[0],$files[1])){
   echo "$files[0] copy success";
  }else{
   echo "$files[0] rename failed";
  }
 }elseif(is_file($files[0])){
  if(copy($files[0],$files[1])) {
   echo "$files[0] copy success";
  }else{
   echo "$files[0] rename failed";
  }
 }else{
  echo "没找到文件";
 }
}

function copydir($dirf,$dirt){//目录拷贝函数
    $mydir=@opendir($dirf);
 if(!@mkdir($dirt))return false;
    while($file=@readdir($mydir)){
        if((is_dir("$dirf/$file"))&&($file!=".")&&($file!="..")){
   if(!@copydir("$dirf/$file","$dirt/$file"))return false;
        }elseif(is_file("$dirf/$file")){
   if(!@copy("$dirf/$file","$dirt/$file"))return false;
  }
 }
    return true;
}

昨天写的~~ -_-.......... //传参数为 c:\test\|||c:\ttt\ 

函数自动讲 c:\test\ 拷贝为 c:\ttt\ 

 



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template