title: Codeigniter read from directory failed
body: <p>I changed and now it does not show nothing. The directories exist on the folder.</p>
  
  <p>i am giving you an example. If i echo $dir i get fullurlpath/root_folder/username</p>
  
  <p>the whole path and directories exist so the $dir is ok, something else must happend. </p>
  
  <p>class Front_Page extends CI_Model{</p>
  
  <pre><code>function front_display(){
  
      $this-&gt;db-&gt;select('id, username');
      $query = $this-&gt;db-&gt;get('models')-&gt;result();
  
      $display_models = '&lt;ul class="display-models"&gt;';
  
      foreach ($query as $row){
  
  
          $username= $row-&gt;username;
  
          $dir = base_url('/img/'.$username.'');
          echo $dir;
          if(is_dir($dir)){
              if($dh = opendir($dir)){
                  while(($file = readdir($dh)) !== FALSE){            
  
                      $display_models .= '&lt;li&gt;';
                      $display_models .= '&lt;a href="profilepage/'.$row-&gt;id.'"&gt;';
                      $display_models .= '&lt;img src="'.$dir.'/'.$file.'"&gt;';
                      $display_models .= '&lt;/a&gt;';
                      $display_models .= '&lt;/li&gt;';
  
                  }
  
                  closedir($dh);
              }
          }
      }
  
          $display_models .= '&lt;/ul&gt;';
  
          return $display_models;
  }
  </code></pre>
  
  <p>}</p>