You are here

function upload_delete in Drupal 5

Same name and namespace in other branches
  1. 4 modules/upload.module \upload_delete()
  2. 6 modules/upload/upload.module \upload_delete()
1 call to upload_delete()
upload_nodeapi in modules/upload/upload.module
Implementation of hook_nodeapi().

File

modules/upload/upload.module, line 733
File-handling and attaching files to nodes.

Code

function upload_delete($node) {
  $files = array();
  $result = db_query('SELECT * FROM {files} WHERE nid = %d', $node->nid);
  while ($file = db_fetch_object($result)) {
    $files[$file->fid] = $file;
  }
  foreach ($files as $fid => $file) {

    // Delete all file revision information associated with the node
    db_query('DELETE FROM {file_revisions} WHERE fid = %d', $fid);
    file_delete($file->filepath);
  }

  // Delete all files associated with the node
  db_query('DELETE FROM {files} WHERE nid = %d', $node->nid);
}