Copy entire contents of a directory into another directory using php


function recursive_copy($src, $dst)
{
    $dir = opendir($src);
    if (!is_dir($dst)) {
        @mkdir($dst);
    }
    while (false !== ($file = readdir($dir))) {
        if (($file != '.') && ($file != '..')) {
            if (is_dir($src . '/' . $file)) {
                recursive_copy($src . '/' . $file, $dst . '/' . $file);
            } else {
                copy($src . '/' . $file, $dst . '/' . $file);
            }
        }
    }
    closedir($dir);
}

I found this function at http://stackoverflow.com/questions/2050859/copy-entire-contents-of-a-directory-to-another-using-php.

Its working perfect !! Try it and leave your comments..

enjoy..

Advertisements

I like to hear from you about this !!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s