title: Codeigniter, Add subfolders and files in a treeview
body: <p>I am trying to implement a treeview where users can add subfolders and files. </p>
  
  <p>I'm using codeigniter and jquery for this , I can see the treeview structure but i don't know how i can implement the directory and file creation(managing) functionality.</p>
  
  <p>For example, in country 1, citrus subfolder i'd like to add another folder and then files to this new folder.</p>
  
  <p>![ treeview ][1]</p>
  
  <p>[VIEW] :</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;Files&lt;/title&gt;
  &lt;script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;style type="text/css"&gt;
  
   ul { list-style: none;
        padding-left: 20px;
        cursor: pointer;
    }
    li {
        padding-left: 20px;
        margin:2px;
    }
  
    .folder { background:#eee  url('../img/16x16/folder.png') no-repeat;
               }
    .file { background:#eee url('../img/16x16/file.png') no-repeat;}   
  
  &lt;/style&gt; 
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;div id="files"&gt;
  &lt;?php //print_r($folders);?&gt;
  &lt;/div&gt;
  
  &lt;div id="files-operation"&gt;
  
  &lt;/div&gt;  
  
  &lt;script type="text/javascript"&gt;
  
  $(document).ready(function() {
  var files = &lt;?php echo json_encode($folders); ?&gt;;
  var file_tree = build_file_tree(files);
  file_tree.appendTo('#files');
  
  
  function build_file_tree(files) {
  
      var tree = $('&lt;ul&gt;');
  
      for (x in files) {
  
          if (typeof files[x] == "object") {
              var span = $('&lt;span&gt;').html(x).appendTo(
                  $('&lt;li&gt;').appendTo(tree).addClass('folder')
              );
              var subtree = build_file_tree(files[x]).hide();
              span.after(subtree);
              span.click(function() {
                  $(this).parent().find('ul:first').toggle();
              });
  
          } else {
              $('&lt;li&gt;').html(files[x]).appendTo(tree).addClass('file').click(function(){
                  window.location=$(this).find("a").attr("href");return false;})
  
  
          }
  
      }
  
      return tree;
  
  }
  });  
  
  &lt;/script&gt;
  </code></pre>
  
  <p>
        </p>
  
  <p>[CONTROLLER] :</p>
  
  <pre><code>function display()
  {
      $data['folders'] = directory_map('./vinefresh/');
      $data['contenido'] = "index";
      $this-&gt;load-&gt;view('plantilla',$data);
  }
  </code></pre>
  
  <p>My goal is to be able to make subdirectories and adding files dynamicaly, but how do i get the path if i want to create a subfolder within Citrus or any other subfolder? </p>
  
  <p>thanks in advance</p>