Php – Deleting a File using php/codeigniter


I would like to delete a file that is found in my localhost.


I'm using codeigniter for this.

I would like to use the unlink() function in php but I really can't understand how to use it.

Best Solution

you can use the "file helper" in codeigniter.

CodeIgniter v3:

CodeIgniter v4:

and like this :


Late Edit: delete_filesmethod uses a path to wipe out all of its contents via unlink() and same you can do within CI. Like this:


a valid path.