Import FTP uploaded site graphics into site graphics

From FundaWiki

Jump to: navigation, search

Small script you can use to have the webserver copy files and directories into the webserver owned site_graphics directory. This can be used when moving a site from one host to another and you don't want to upload all those files again.


function copyDir($srcPath, $destPath) {
    foreach (glob($srcPath .'/*') as $entry) {
        if (is_dir($entry)) {
            mkdir($destPath . '/' .  basename($entry));
            copyDir($entry, $destPath . '/' . basename($entry));
        }

        if (is_file($entry)) {
            copy($entry, $destPath . '/' . basename($entry));
        }
    }
}

copyDir(constant('SCRIPT_ROOT') .'import/site_graphics', constant('SCRIPT_ROOT') .'fundanemt/site_graphics');
Personal tools