in my project i have a table named portfolio, which has an attribute called images. in that attribute i am saving the image location like ‘uploads/1.jpg‘. i don’t have any problem with file uploading issue.
when i delete an row from my database table, i am only deleting the row but the file still exists in the uploads directory in my local sever. i want to delete the file also, when i am deleting the row from the database.
i have seen the ftp class in codeigniter documentation, but the document says that i need to configure a ftp host. but currently i am using the localhost server wamp for my project and haven’t uploaded it yet in the main server. so, how do i delete a file from it’s directory when i am deleting the row from the database using codeigniter? can anyone help?
i am using codeigniter 2.1.0 and mySQL database for my project.
in my project i have a table named portfolio, which has an attribute called
Share
Use the
unlink()function.http://www.php.net/manual/en/function.unlink.php
Ex: