How to delete uploaded image from directory folder in CodeIgniter
unlink(base_url("uploads/".$group_picture));
Should be
unlink("uploads/".$group_picture);
You need the path, not the url.
Use CI constant FCPATH
as location of root directory, so in your case that should be:
unlink( FCPATH . "uploads/" . $group_picture );
Notice that FCPATH
already has trailing slash.
To delete a file/picture you can use delete_files()
function. First load the file helper and then pass the file path as a first parameter in the delete_files()
function and true
as the second.like-
delete_files($path, true);