function upload_delete in Drupal 6
Same name and namespace in other branches
- 4 modules/upload.module \upload_delete()
- 5 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 430 - File-handling and attaching files to nodes.
Code
function upload_delete($node) {
$files = array();
$result = db_query('SELECT DISTINCT f.* FROM {upload} u INNER JOIN {files} f ON u.fid = f.fid WHERE u.nid = %d', $node->nid);
while ($file = db_fetch_object($result)) {
$files[$file->fid] = $file;
}
foreach ($files as $fid => $file) {
// Delete all files associated with the node
db_query('DELETE FROM {files} WHERE fid = %d', $fid);
file_delete($file->filepath);
}
// Delete all file revision information associated with the node
db_query('DELETE FROM {upload} WHERE nid = %d', $node->nid);
}