file.inc

API for handling file uploads and server file management.

File

drupal/core/includes/file.inc
View source

Functions

Namesort descending Description
drupal_basename Gets the filename from a given path.
drupal_chmod Sets the permissions on a file or directory.
drupal_dirname Gets the name of the directory from a given path.
drupal_mkdir Creates a directory using Drupal's default mode.
drupal_move_uploaded_file Moves an uploaded file to a new location.
drupal_realpath Returns the absolute local filesystem path of a stream URI.
drupal_rmdir Removes a directory.
drupal_tempnam Creates a file with a unique filename in the specified directory.
drupal_unlink Deletes a file.
file_build_uri Constructs a URI to Drupal's default files location given a relative path.
file_create_filename Creates a full file path from a directory and filename.
file_create_url Creates a web-accessible URL for a stream to an external or local file.
file_default_scheme Gets the default file stream implementation.
file_delete Deletes a file and its database record.
file_delete_multiple Deletes files.
file_destination Determines the destination path for a file.
file_directory_temp Gets the path of system-appropriate temporary directory.
file_download Page callback: Handles private file transfers.
file_ensure_htaccess Creates a .htaccess file in each Drupal files directory if it is missing.
file_get_mimetype Determines an Internet Media Type or MIME type from a filename.
file_get_stream_wrappers Provides Drupal stream wrapper registry.
file_munge_filename Modifies a filename as needed for security purposes.
file_prepare_directory Checks that the directory exists and is writable.
file_save_htaccess Creates a .htaccess file in the given directory.
file_save_upload Saves a file upload to a new location.
file_scan_directory Finds all files that match a given mask in a given directory.
file_stream_wrapper_get_class Returns the stream wrapper class name for a given scheme.
file_stream_wrapper_get_instance_by_scheme Returns a reference to the stream wrapper class responsible for a scheme.
file_stream_wrapper_get_instance_by_uri Returns a reference to the stream wrapper class responsible for a given URI.
file_stream_wrapper_uri_normalize Normalizes a URI by making it syntactically correct.
file_stream_wrapper_valid_scheme Checks that the scheme of a stream URI is valid.
file_transfer Transfers a file to the client using HTTP.
file_unmanaged_copy Copies a file to a new location without invoking the file API.
file_unmanaged_delete Deletes a file without database changes or hook invocations.
file_unmanaged_delete_recursive Deletes all files and directories in the specified filepath recursively.
file_unmanaged_move Moves a file to a new location without database changes or hook invocation.
file_unmanaged_save_data Saves a file to the specified destination without invoking file API.
file_unmunge_filename Undoes the effect of file_munge_filename().
file_upload_max_size Determines the maximum file upload size by querying the PHP settings.
file_uri_scheme Returns the scheme of a URI (e.g. a stream).
file_uri_target Returns the part of a URI after the schema.
file_valid_uri Determines whether the URI has a valid scheme for file API operations.

Constants

Namesort descending Description
FILE_CREATE_DIRECTORY Flag used by file_prepare_directory() -- create directory if not present.
FILE_EXISTS_ERROR Flag for dealing with existing files: Do nothing and return FALSE.
FILE_EXISTS_RENAME Flag for dealing with existing files: Appends number until name is unique.
FILE_EXISTS_REPLACE Flag for dealing with existing files: Replace the existing file.
FILE_MODIFY_PERMISSIONS Flag used by file_prepare_directory() -- file permissions may be changed.
FILE_STATUS_PERMANENT Indicates that the file is permanent and should not be deleted.
STREAM_WRAPPERS_ALL Stream wrapper bit flag -- a filter that matches all wrappers.
STREAM_WRAPPERS_HIDDEN Stream wrapper type flag -- not visible in the UI or accessible via web, but readable and writable. E.g. the temporary directory for uploads.
STREAM_WRAPPERS_LOCAL Stream wrapper bit flag -- refers to a local file system location.
STREAM_WRAPPERS_LOCAL_HIDDEN Stream wrapper type flag -- hidden, readable and writeable using local files.
STREAM_WRAPPERS_LOCAL_NORMAL Stream wrapper type flag -- visible, readable and writeable using local files.
STREAM_WRAPPERS_NORMAL Stream wrapper type flag -- the default when 'type' is omitted from hook_stream_wrappers(). This does not include STREAM_WRAPPERS_LOCAL, because PHP grants a greater trust level to local files (for example, they can be used in an…
STREAM_WRAPPERS_READ Stream wrapper bit flag -- wrapper is readable (almost always true).
STREAM_WRAPPERS_READ_VISIBLE Stream wrapper type flag -- visible and read-only.
STREAM_WRAPPERS_VISIBLE Stream wrapper bit flag -- exposed in the UI and potentially web accessible.
STREAM_WRAPPERS_WRITE Stream wrapper bit flag -- wrapper is writeable.
STREAM_WRAPPERS_WRITE_VISIBLE Stream wrapper type flag -- visible, readable and writeable.