title: How Delete File and Image after upload from Codeigniter?
body: <p>This my code controllers "contract.php"</p>
  
  <pre><code>function delete($con_id){
          //$year=$this-&gt;session-&gt;userdata('year');
          $path = ('/assets/upload/employees/contracts/');
          $get_file = $path.$con_id.'.jpg';
          $this-&gt;db-&gt;where('con_id',$con_id);
          $this-&gt;db-&gt;delete('sch_emp_contract');
          if(file_exists($get_file)){
              unlink(base_url("/assets/upload/employees/contracts/'.$con_id."));
          }
  
          $m='';
          $p='';
          if(isset($_GET['m'])){
              $m=$_GET['m'];
          }
          if(isset($_GET['p'])){
              $p=$_GET['p'];
          }
  
          redirect("employee/contract?m=$m&amp;p=$p");
      }
  </code></pre>
  
  <p>This code View contract_list.php 
  - Button Delete</p>
  
  <pre><code>&lt;td width="1%" class="remove_tag"&gt;';
       if($this-&gt;green-&gt;gAction("D")){
       $tr .='&lt;a title="Delete Contract" id="clk_del" class="clk_del"&gt;
  &lt;img rel="'.$contract['con_id'].'" src="'.site_url('../assets/images/icons/delete.png').'" onclick="delete_contrac (event);" style="width:20px;height:20px;"&gt;&lt;/a&gt;';}$tr .='&lt;/td&gt;
  </code></pre>
  
  <p>Function</p>
  
  <pre><code>function delete_contract(event){
      var r = confirm("Are you sure to delete this record !");
      if( r == true){
      var contr_id= $(event.target).attr('rel');
      location.href="&lt;?PHP echo site_url('employee/contract/delete');?&gt;/"+contr_id+"?&lt;?php echo "m=$m&amp;p=$p" ?&gt;";
      }
  }
  </code></pre>
  
  <p>Success Delete from Database but Folder file and Image upload can't delete.  </p>