title: Codeigniter Recursively Copy Folders and Files
body: <p>I have the  following function which is supposed to help copy folders and files inside folders and files. I would like to copy the following source : </p>
  
  <pre><code>Documents/Projects/Sensitization Workshop Meeting/Milestones/Activity No 1/Tasks/Task One/New File.txt
  </code></pre>
  
  <p>To the  following destination : </p>
  
  <pre><code>Documents/Projects/Sensitization Workshop Meeting/Milestones/Asqwerty/Tasks/Task One/ New File.txt
  </code></pre>
  
  <p>So the  folder changing is Activity No 1 -> Asqwerty , 
  I tried the  following function but it didn't work : </p>
  
  <pre><code> // copy recursive
      function recursive_copy($source, $dest) {
          if (is_dir($source)) {
              $dir_handle = opendir($source);
  
              while ($file = readdir($dir_handle)) {
                  if ($file != "." &amp;&amp; $file != "..") {
                      if (is_dir($source . "/" . $file)) {
                          if (!is_dir($dest . "/" . $file)) {
  
                              mkdir($dest . "/" . $file, 0777, TRUE);
                          }
  
                          $this-&gt;recurse_copy($source . '/' . $file, $dest . '/' . $file);
                      } else {
  
                          copy($source . "/" . $file, $dest . "/" . $file);
                      }
                  }
              }
              closedir($dir_handle);
          } else {
              copy($source, $dest);
          }
      }
  </code></pre>
  
  <p>But it only copies to the following level : </p>
  
  <pre><code>Source : Documents/Projects/Sensitization Workshop Meeting/Milestones/Activity No 1/Tasks
  
  
  Destination : Documents/Projects/Sensitization Workshop Meeting/Milestones/Asqwerty/Tasks
  </code></pre>
  
  <p>How can I sought this out ? </p>