Return to Snippet

Revision: 66357
at April 22, 2014 21:24 by fedek6


Initial Code
// copy recursive
function cpy($source, $dest){
    if(is_dir($source)) {
        $dir_handle=opendir($source);
        while($file=readdir($dir_handle)){
            if($file!="." && $file!=".."){
                if(is_dir($source."/".$file)){
                    if(!is_dir($dest."/".$file)){
                        mkdir($dest."/".$file);
                    }
                    cpy($source."/".$file, $dest."/".$file);
                } else {
                    copy($source."/".$file, $dest."/".$file);
                }
            }
        }
        closedir($dir_handle);
    } else {
        copy($source, $dest);
    }
}

Initial URL

                                

Initial Description
Copy all files and directories from src to dest.

Initial Title
Copy files and folder recursive

Initial Tags
copy

Initial Language
PHP