zoreli — 2011-08-18T10:28:47-04:00 — #1
On my website, I have added the possibility for the users to upload their photos. I do have a back office from where I can delete some of the images that do not comply with the site policy.
However, I am deleting only the record from the database, not the actual image from the folder where it is uploaded.
Record in the database field look like 150068imagename.jpg for example. I do have added time stamp to each image to prevent duplicate images names.
What I would like to accomplish is not only to delete the record, but to delete and the actual file from the folder which is located on the server where the site is hosted. Anyone can tell me if and how can I accomplish this?
scallioxtx — 2011-08-18T10:50:54-04:00 — #2
You can use the unlink function to delete files from the hard disk. Just execute that once you've removed the row from the database (not before, because then if the deletion of the row fails you're in a situation where you have a row pointing to an image that does not exist, which may cause nasty errors on your website).
zoreli — 2011-08-18T11:48:33-04:00 — #3
Thanks mate...I will give it a try, hopefully it will work...