Jump to content

moving a whole Dir


adam291086

Recommended Posts

I found this function ages ago through google

function full_copy($source, $target,$new ) {
        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 );
        }
    }

 

Heres the problem if i have the following folder structure

 

Folder Adam which contains

 

Folder john

file adam.php

file index.php

 

Folder john contains

file index.php

 

When i go to call on the function all the files and folders within Adam are copied across but not into a folder called Adam there is just the folder called john with its files and the other two files. I know i need to mkdir($source) at the start of the function but i am stuck with how to get everything to go into that folder.

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/123232-moving-a-whole-dir/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.