Delete files from a server from a MYSQL trigger

0

Dear friends:

I have the following code in a MYSQL trigger

CREATE DEFINER = CURRENT_USER TRIGGER 'mfnmlsbase'.'post_BEFORE_DELETE' BEFORE DELETE ON 'post' FOR EACH ROW
BEGIN
DELETE FROM ficheros WHERE ficheros.fic_token_padre = old.pos_token;
END

As you can see, deleting a record in the 'post' table also deletes all associated records from the table files, which basically contains urls of the files (images) related to the record deleted in the post table.

The question. Can the trigger be modified to also delete the server files? Ie the images. Since now, the images used by the post deleted, remain as files on the server that are not used by any other post.

Maybe it is not possible and it is necessary to delete them from PHP. Can anyone throw some light on this?

Thank you for your time

    
asked by ManoFerro 24.01.2018 в 17:07
source

0 answers