Deleting image as well, not only the record

Hi

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?

Regards, Zoreli

You can use the [fphp]unlink[/fphp] 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).

Thanks mate…I will give it a try, hopefully it will work…

Regards, Zoreli