Folders and its files do get copied.. pls help me in given code..

Posted by OM The Eternity on Stack Overflow See other posts from Stack Overflow or by OM The Eternity
Published on 2010-05-07T06:56:33Z Indexed on 2010/05/07 6:58 UTC
Read the original article Hit count: 179

Filed under:
|

I have a joomla folder, and i have a script which has to copy the complete joomla folder to another new folder..below is the code which copies only the files contain in the main folder but NOT the other directories existing in the joomla folder, I know that i have to plcae some check for dir_exist function and create it if do not exist.. also I want this code to perform a function to overrite the previously existing files and folders.. how can i accomplish thisss??????

<?php
$source = '/var/www/html/pranav_test/';
$destination = '/var/www/html/parth/';
$sourceFiles = glob($source . '*');
foreach($sourceFiles as $file) {
   $baseFile = basename($file);
    if (file_exists($destination . $baseFile)) {
        $originalHash = md5_file($file);
        $destinationHash = md5_file($destination . $baseFile);
        if ($originalHash === $destinationHash) {
            continue;
        }
    }
    copy($file, $destination . $baseFile);
}
?>

Thanks to @alex who helped me to get the code... But I need more support pls help...

© Stack Overflow or respective owner

Related posts about php

Related posts about copy