File interface

  1. 7.x drupal/includes/ file
  2. 5.x drupal/includes/ file
  3. 6.x drupal/includes/ file
  4. 8.x drupal/core/includes/ file

Common file handling functions.


Namesort descending Location Description
file_check_directory drupal/includes/ Check that the directory exists and is writable. Directories need to have execute permissions to be considered a directory by FTP servers, etc.
file_check_location drupal/includes/ Check if a file is really located inside $directory. Should be used to make sure a file specified is really located within the directory to prevent exploits.
file_check_path drupal/includes/ Checks path to see if it is a directory, or a dir/file.
file_check_upload drupal/includes/ Verify an uploaded file.
file_copy drupal/includes/ Copies a file to a new location. This is a powerful function that in many ways performs like an advanced version of copy().
file_create_filename drupal/includes/ Create a full file path from a directory and filename. If a file with the specified name already exists, an alternative will be used.
file_create_path drupal/includes/ Make sure the destination is a complete path and resides in the file system directory, if it is not prepend the file system directory.
file_create_url drupal/includes/ Create the download path to a file.
file_delete drupal/includes/ Delete a file.
file_directory_path drupal/includes/ Determine the default 'files' directory.
file_directory_temp drupal/includes/ Determine the default temporary directory.
file_download drupal/includes/
file_get_mimetype drupal/includes/ Determine an Internet Media Type, or MIME type from a filename.
file_move drupal/includes/ Moves a file to a new location.
file_save_data drupal/includes/ Save a string to the specified destination.
file_save_upload drupal/includes/ Saves a file upload to a new location. The source file is validated as a proper upload and handled as such.
file_scan_directory drupal/includes/ Finds all files that match a given mask in a given directory. Directories and files beginning with a period are excluded; this prevents hidden files and directories (such as SVN working directories) from being scanned.
file_transfer drupal/includes/ Transfer file using http to client. Pipes a file through Drupal to the client.
file_upload_max_size drupal/includes/ Determine the maximum file upload size by querying the PHP settings.


Namesort descending Location Description
FILE_CREATE_DIRECTORY drupal/includes/
FILE_DOWNLOADS_PUBLIC drupal/includes/
FILE_EXISTS_ERROR drupal/includes/
FILE_EXISTS_RENAME drupal/includes/
FILE_EXISTS_REPLACE drupal/includes/


drupal/includes/, line 8
API for handling file uploads and server file management.