title: Delete all files in one directory with Codeigniter
body: <p>I've got one problem when I want to delete all files in one directory with Codeigniter..</p>
  
  <p>I've been watching and trying from any tutorials, and just having one problem.. It always can't delete any files.</p>
  
  <p>here's my script :</p>
  
  <p>@view</p>
  
  <pre><code>&lt;a href="&lt;?php echo base_url()?&gt;sia/delete_allfile" title="Delete All File" onclick="return confirm('Are you sure you want delete all files?')"&gt;Delete All File&lt;/a&gt;
  </code></pre>
  
  <p>@controller</p>
  
  <pre><code>public function delete_allfile()
  {
      $files = glob($_SERVER['DOCUMENT_ROOT'].'upload/perizinan/*'); // get all file names
      if(is_dir($path))
      {
          $this-&gt;session-&gt;set_flashdata('message',
          '
              Wrong directory !
          ');
          redirect('sia/perizinan');
      }else
      {
          foreach($files as $file)
          { // iterate files
              if(is_file($file))
              unlink($file); // delete file
          }
          redirect('sia/perizinan');
      }
  }
  </code></pre>