copy folder contect to anthor folder php

Solutions on MaxInterview for copy folder contect to anthor folder php by the best coders in the world

showing results for - "copy folder contect to anthor folder php"
Alexis
06 Jan 2017
1public function recurseCopy($src,$dst, $childFolder='') { 
2
3    $dir = opendir($src); 
4    mkdir($dst);
5    if ($childFolder!='') {
6        mkdir($dst.'/'.$childFolder);
7
8        while(false !== ( $file = readdir($dir)) ) { 
9            if (( $file != '.' ) && ( $file != '..' )) { 
10                if ( is_dir($src . '/' . $file) ) { 
11                    $this->recurseCopy($src . '/' . $file,$dst.'/'.$childFolder . '/' . $file); 
12                } 
13                else { 
14                    copy($src . '/' . $file, $dst.'/'.$childFolder . '/' . $file); 
15                }  
16            } 
17        }
18    }else{
19            // return $cc; 
20        while(false !== ( $file = readdir($dir)) ) { 
21            if (( $file != '.' ) && ( $file != '..' )) { 
22                if ( is_dir($src . '/' . $file) ) { 
23                    $this->recurseCopy($src . '/' . $file,$dst . '/' . $file); 
24                } 
25                else { 
26                    copy($src . '/' . $file, $dst . '/' . $file); 
27                }  
28            } 
29        } 
30    }
31    
32    closedir($dir); 
33}
34