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