php copy filesteemCreated with Sketch.

in php •  7 years ago  (edited)
// php copy file

function copyR($src, $dst){
    if (! is_dir($src)) return;
    @mkdir($dst);
    $files = scandir($src);
    foreach ($files as $file) {
        if ($file == '.' || $file == '..')
            continue;
        copy1("$src/$file", "$dst/$file");
    }
}
function copy1($src, $dst){
    if ($src == '.' || $src == '..' || $dst == '.' || $dst == '..')
        return;
    if (is_dir($src))
        copyR($src, $dst);
    else if (is_link($src))
        symlink(readlink($src), $dst);
    else
        copy($src, $dst);
}
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!