Issue
I am trying to delete a file whose name is saved in $category_image
. But the function delete_files()
is not deleting.
public function deleteCategory($id,$category_image)
{
$this->load->helper('file');
//echo FCPATH.'/uploads/'.$category_image;
delete_files(FCPATH.'/uploads/'.$category_image,false,false);die;
//$this->load->model('AdminModel')->deleteCategory($id);
}
Solution
The problem is that delete_files()
is the wrong function to use. It is designed to "Deletes all files contained in the supplied directory path." - not to delete a single file. The addition of a file name at the end of the path causes the function to fail.
Just use unlink()
unlink(FCPATH.'uploads/'.$category_image);die;
Note that the constant FCPATH
already has a directory separator at the end so don't add another before 'uploads/'
.
Answered By - DFriend
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.