Skip to content

Delete Callback - Delete some Files when record is deleted from a table

You can use DETELE trigger to delete files using sys_exec (MySQL)
CREATE TRIGGER foobar
AFTER DELETE ON photo
FOR EACH ROW
BEGIN
   CALL sys_exec(concat('/bin/rm -f ',filename));
END
HOWEVER, IT IS NOT RECOMMENDED.

A much better (and safer) practice is to leave the files simply on the server and run a separate batch script daily to remove the files.

Feedback and Knowledge Base