W3cubDocs

/Drupal 8

function file_delete

file_delete($fid)

Deletes a file and its database record.

Instead of directly deleting a file, it is strongly recommended to delete file usages instead. That will automatically mark the file as temporary and remove it during cleanup.

Parameters

$fid: The file id.

See also

file_unmanaged_delete()

\Drupal\file\FileUsage\FileUsageBase::delete()

Related topics

File interface
Common file handling functions.

File

core/includes/file.inc, line 810
API for handling file uploads and server file management.

Code

function file_delete($fid) {
  return file_delete_multiple(array($fid));
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!file.inc/function/file_delete/8.1.x