CodeIgniter Forums
How do I delete a single file? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How do I delete a single file? (/showthread.php?tid=33940)



How do I delete a single file? - El Forum - 09-13-2010

[eluser]Unknown[/eluser]
Hey guys.

I've just recently started to learn CodeIgniter and have just begun playing with the file uploading class. I've been looking around a bit for how I can delete a single file which has been uploaded but all I've found is the function
Code:
delete_files()
which deletes all files in a directory..

So, how should I delete a single file?


How do I delete a single file? - El Forum - 09-13-2010

[eluser]CroNiX[/eluser]
regular php?

unlink('path/to/file');


How do I delete a single file? - El Forum - 09-14-2010

[eluser]LinkFox[/eluser]
Yeah don't be afraid to use regular PHP Smile

Unlink() is the the one you need...but remember you have to give unlink() an absolute path to the file not a URL or you could have people remotely deleting files via HTTP!