Sunday, June 24, 2012

PHP Script to copy directory

<?php
function full_copy($source,$target)
{
        if(is_dir($source))
        {
            @mkdir($target);
            $d = dir($source);
            while(FALSE !== ($entry = $d->read()))
            {
                if($entry == '.' || $entry == '..')
                {
                    continue;
                }
                $Entry = $source . '/' . $entry;         
                if(is_dir($Entry))
                {
                    full_copy( $Entry, $target . '/' . $entry );
                    continue;
                }
                copy($Entry,$target.'/'.$entry);
            }
            $d->close();
        }
        else
        {
            copy($source,$target);
        }
}
$strSubdomain = "SIS";
/// absolute path///////
$strSource = $dir['root']."resources/affiliate/";
$strDest = $dir['root']."subdomain/affiliate/$strSubdomain";
full_copy($strSource,$strDest);   
?>

No comments:

Post a Comment

Please mention your comments.......