Not able to delete images from 'uploads' folders in Codeigniter
<p>I am trying to delete all user data including all images from 'uploads' folder when deleted a record in XAMPP. So far it is deleting rows from table but for the images from upload folder I get this error,</p>

<blockquote>
  <p>Message: unlink(uploads/property-images/): Permission denied</p>
</blockquote>

<p>When I <code>print_r($rowId);</code> from model it echo the images array fine. I am sure that I may be doing something wrong in model as delete function has to be an array on it but I am not sure how to do that.</p>

<p>But at the same time in my other scripts I have successfully deleted and replace user's profile picture using unlink.. I guess if that worked than 'Permission' shouldn't be the problem this time.. The only difference is that this time I have an array of images exploded in script.</p>

<p>In my controller:</p>

<pre><code>function delete_listing_id() {
    if($this-&gt;session-&gt;userdata('is_logged_in')){
    $id = $this-&gt;uri-&gt;segment(3);
    $images_urls = $this-&gt;my_listings_model-&gt;get_property_all_images_url($id);
    $this-&gt;my_listings_model-&gt;delete_listing_images($images_urls);

    $this-&gt;my_listings_model-&gt;delete_listing_id($id);

    $this-&gt;my_listings();
}
</code></pre>

<p>Model:</p>

<pre><code>function get_property_all_images_url($id) {
    $this-&gt;db-&gt;select('property_images');
    $this-&gt;db-&gt;from('vbc_property_images');
    $this-&gt;db-&gt;where('property_ref_id', $id);
    $query = $this-&gt;db-&gt;get();

$query_result = $query-&gt;result_array();
if (empty($query_result)) {
    return FALSE;
}
elseif (count($query_result) &gt; 1) {
    return 0;
}
else{
    $rowId = explode(',',$query_result[0]['property_images']);
    return $rowId;    
    }
}

function delete_listing_id($id){
    $this-&gt;db-&gt;delete('vbc_vacation_item_attri', array('vbc_item_id' =&gt; $id));
    $this-&gt;db-&gt;delete('vbc_property_amenities', array('v_ref_id' =&gt; $id));
    $this-&gt;db-&gt;delete('vbc_property_images', array('property_ref_id' =&gt; $id));
}

function delete_listing_images($images_urls) {
    unlink('uploads/property-images/'.$images_urls);
    return TRUE;
}
</code></pre>