Common file handling functions.

Fields on the file entity:

  • fid: File ID
  • uid: The {users}.uid of the user who is associated with the file.
  • filename: Name of the file with no path components. This may differ from the basename of the filepath if the file is renamed to avoid overwriting an existing file.
  • uri: URI of the file.
  • filemime: The file's MIME type.
  • filesize: The size of the file in bytes.
  • status: A bitmapped field indicating the status of the file. The first 8 bits are reserved for Backdrop core. The least significant bit indicates temporary (0) or permanent (1). Temporary files older than BACKDROP_MAXIMUM_TEMP_FILE_AGE will be removed during cron runs.
  • timestamp: UNIX timestamp for the date the file was added to the database.

File

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

Functions

Namesort descending Location Description
backdrop_basename includes/file.inc Gets the filename from a given path.
backdrop_chmod includes/file.inc Sets the permissions on a file or directory.
backdrop_dirname includes/file.inc Gets the name of the directory from a given path.
backdrop_mkdir includes/file.inc Creates a directory using Backdrop's default mode.
backdrop_move_uploaded_file includes/file.inc Moves an uploaded file to a new location.
backdrop_realpath includes/file.inc Resolves the absolute filepath of a local URI or filepath.
backdrop_rmdir includes/file.inc Removes a directory.
backdrop_tempnam includes/file.inc Creates a file with a unique filename in the specified directory.
backdrop_unlink includes/file.inc Deletes a file.
file_build_uri includes/file.inc Constructs a URI to Backdrop's default files location given a relative path.
file_copy includes/file.inc Copies a file to a new location and adds a file record to the database.
file_create_filename includes/file.inc Creates a full file path from a directory and filename.
file_create_url includes/file.inc Creates a web-accessible URL for a stream to an external or local file.
file_default_scheme includes/file.inc Gets the default file stream implementation.
file_delete includes/file.inc Deletes a file and its database record.
file_delete_multiple includes/file.inc Deletes files.
file_destination includes/file.inc Determines the destination path for a file.
file_directory_temp includes/file.inc Gets the path of system-appropriate temporary directory.
file_download includes/file.inc Page callback: Handles private file transfers.
file_download_access includes/file.inc Checks that the current user has access to a particular file.
file_download_headers includes/file.inc Retrieves headers for a private file download.
file_ensure_htaccess includes/file.inc Creates a .htaccess file in each files directory if it is missing.
file_get_content_headers includes/file.inc Examines a file entity and returns appropriate content headers for download.
file_get_mimetype includes/file.inc Determines an Internet Media Type or MIME type from a filename.
file_get_stream_wrappers includes/file.inc Provides Backdrop stream wrapper registry.
file_htaccess_lines includes/file.inc Returns the standard .htaccess lines that Backdrop adds to file directories.
file_load includes/file.inc Loads a single file entity from the database.
file_load_multiple includes/file.inc Loads file entities from the database.
file_move includes/file.inc Moves a file to a new location and update the file's database entry.
file_munge_filename includes/file.inc Modifies a filename as needed for security purposes.
file_prepare_directory includes/file.inc Checks that the directory exists and is writable.
file_save includes/file.inc Saves a new or updated file.
file_save_data includes/file.inc Saves a file to the specified destination and creates a database entry.
file_save_htaccess includes/file.inc Creates a .htaccess file in the given directory.
file_save_upload includes/file.inc Saves a file upload to a new location.
file_scan_directory includes/file.inc Finds all files that match a given mask in a given directory.
file_space_used includes/file.inc Determines total disk space used by a single user or the whole filesystem.
file_stream_wrapper_get_class includes/file.inc Returns the stream wrapper class name for a given scheme.
file_stream_wrapper_get_instance_by_scheme includes/file.inc Returns a reference to the stream wrapper class responsible for a scheme.
file_stream_wrapper_get_instance_by_uri includes/file.inc Returns a reference to the stream wrapper class responsible for a given URI.
file_stream_wrapper_uri_normalize includes/file.inc Normalizes a URI by making it syntactically correct.
file_stream_wrapper_valid_scheme includes/file.inc Checks that the scheme of a stream URI is valid.
file_transfer includes/file.inc Transfers a file to the client using HTTP.
file_unmanaged_copy includes/file.inc Copies a file to a new location without database changes or hook invocation.
file_unmanaged_delete includes/file.inc Deletes a file without database changes or hook invocations.
file_unmanaged_delete_recursive includes/file.inc Deletes all files and directories in the specified filepath recursively.
file_unmanaged_move includes/file.inc Moves a file to a new location without database changes or hook invocation. This is a powerful function that in many ways performs like an advanced version of rename().
file_unmanaged_prepare includes/file.inc Internal function that prepares the destination for a file_unmanaged_copy or file_unmanaged_move operation.
file_unmanaged_save_data includes/file.inc Saves a file to the specified destination without invoking file API.
file_unmunge_filename includes/file.inc Undoes the effect of file_munge_filename().
file_upload_max_size includes/file.inc Determines the maximum file upload size by querying the PHP settings.
file_uri_scheme includes/file.inc Returns the scheme of a URI (e.g. a stream).
file_uri_target includes/file.inc Returns the part of a URI after the schema.
file_usage_add includes/file.inc Records that a module is using a file.
file_usage_delete includes/file.inc Removes a record to indicate that a module is no longer using a file.
file_usage_list includes/file.inc Determines where a file is used.
file_validate includes/file.inc Checks that a file meets the criteria specified by the validators.
file_validate_extensions includes/file.inc Checks that the filename ends with an allowed extension.
file_validate_image_orientation includes/file.inc Check for EXIF orientation data and rotate file if needed.
file_validate_image_resolution includes/file.inc Verifies that image dimensions are within the specified maximum and minimum.
file_validate_is_image includes/file.inc Checks that the file is recognized by image_get_info() as an image.
file_validate_name_length includes/file.inc Checks for files with names longer than can be stored in the database.
file_validate_size includes/file.inc Checks that the file's size is below certain limits.
file_valid_uri includes/file.inc Determines whether the URI has a valid scheme for file API operations.

Constants

Namesort descending Location Description
FILE_CREATE_DIRECTORY includes/file.inc Flag used by file_prepare_directory() -- create directory if not present.
FILE_EXISTS_ERROR includes/file.inc Flag for dealing with existing files: Do nothing and return FALSE.
FILE_EXISTS_RENAME includes/file.inc Flag for dealing with existing files: Appends number until name is unique.
FILE_EXISTS_REPLACE includes/file.inc Flag for dealing with existing files: Replace the existing file.
FILE_MODIFY_PERMISSIONS includes/file.inc Flag used by file_prepare_directory() -- file permissions may be changed.
FILE_STATUS_PERMANENT includes/file.inc Indicates that the file is permanent and should not be deleted.