You are here

function upload_delete in Drupal 4

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

File

modules/upload.module, line 629
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);
}