I want my module to delete all images that have been uploaded with its help and delete all database entries from 'file_managed' table on uninstall. I have no problem with the actual file deleting, but I'm stuck with database records deleting. I know there is a file_delete function that removes the database entry as well, but how is it possible to get the required fid then? Thanks in advance.

Comments

xlin’s picture

Did you tried db_delete?

$deleted = db_delete('file_managed') 
->condition('fid', $fid)
->execute();

If you want deleted everything, just remove the condition.

https://api.drupal.org/api/drupal/includes!database!database.inc/functio...