PHP复制文件夹及下面所有文件


 1 function xCopy($source, $destination, $child){   
2   //用法:
3   // xCopy("feiy","feiy2",1):拷贝feiy下的文件到 feiy2,包括子目录
4   // xCopy("feiy","feiy2",0):拷贝feiy下的文件到 feiy2,不包括子目录
5   //参数说明:
6   // $source:源目录名
7   // $destination:目的目录名
8   // $child:复制时,是不是包含的子目录
9
10
11   if(!is_dir($source)){
12     echo("Error:the $source is not a direction!");
13     return 0;
14   }
15
16
17   if(!is_dir($destination)){
18     mkdir($destination,0777);
19   }
20
21   $handle=dir($source);
22   while($entry=$handle->read()) {
23     if(($entry!=".")&&($entry!="..")){
24       if(is_dir($source."/".$entry)){
25         if($child)
26         xCopy($source."/".$entry,$destination."/".$entry,$child);
27       }
28       else{
29         copy($source."/".$entry,$destination."/".$entry);
30       }
31     }
32   }
33
34   return 1;
35 }
36
37 ?>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM