title: Cannot unlink file in Codeigniter
body: <p>In my project I have a folder <strong>secure</strong> in root. The project package looks like:</p>
  
  <pre><code>application 
  secure
  system 
  ...........
  </code></pre>
  
  <p>Inside secure folder I am uploading some images on form submit using</p>
  
  <pre><code>$config1['upload_path'] = './secure/';
  $ext = end(explode(".", $_FILES['thumb_image']['name']));
  $config1['file_name'] = time().$_FILES['thumb_image']['name'];
  $config1['allowed_types'] = 'jpg|png|jpeg|gif|bmp|jpe|tiff|tif';
  $this-&gt;load-&gt;library('upload', $config1);
  $this-&gt;upload-&gt;initialize($config1);
  $this-&gt;upload-&gt;do_upload('thumb_image');
  </code></pre>
  
  <p>and it is working properly. Now while on editing the details, using another form, if I am uploading a new image instead of the current image file, I want to unlink the current one and then upload new file. </p>
  
  <p>For this I am using the code:</p>
  
  <pre><code>unlink(base_url("secure/".$data['row']-&gt;videothumbnail));
  </code></pre>
  
  <p>I also tried with </p>
  
  <pre><code>unlink('/secure/'.$data['row']-&gt;videothumbnail);
  </code></pre>
  
  <p>where <code>$data['row']-&gt;videothumbnail)</code> is the current image file from database. New file is successfully uploaded. But old file is not getting unlinked. I have set the permission of secure folder to <code>777</code>. But the images are uploaded with read only permission. Is it because of this, it is not getting unlinked?</p>
  
  <p>Can anyone help me to solve this?</p>
  
  <p>Thanks in advance.</p>