File interface
Common file handling functions.
Fields on the file object:
- 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 Drupal core. The least sigifigant bit indicates temporary (0) or permanent (1). Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during cron runs.
- timestamp: UNIX timestamp for the date the file was added to the database.
Constants
| Name | 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 | File status -- This bit in the status indicates that the file is permanent and should not be deleted during file garbage collection process. Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during cron runs. |
Functions
| Name | Location | Description |
|---|---|---|
| drupal_chmod | includes/file.inc | Set the permissions on a file or directory. |
| drupal_dirname | includes/file.inc | Gets the name of the directory from a given path. |
| drupal_mkdir | includes/file.inc | Creates a directory using Drupal's default mode. |
| drupal_realpath | includes/file.inc | Returns the absolute path of a file or directory |
| drupal_tempnam | includes/file.inc | Creates a file with a unique filename in the specified directory. |
| file_build_uri | includes/file.inc | Given a relative path, construct a URI into Drupal's default files location. |
| file_copy | includes/file.inc | Copy a file to a new location and adds a file record to the database. |
| file_create_filename | includes/file.inc | Create a full file path from a directory and filename. |
| file_create_htaccess | includes/file.inc | Creates an .htaccess file in the given directory. |
| file_create_url | includes/file.inc | Creates a web-accessible URL for a stream to an external or local file. |
| file_delete | includes/file.inc | Delete a file and its database record. |
| file_destination | includes/file.inc | Determines the destination path for a file depending on how replacement of existing files should be handled. |
| file_directory_path | includes/file.inc | Determines the local directory path of a given wrapper. |
| file_download | includes/file.inc | Menu handler for private file transfers. |
| file_ensure_htaccess | includes/file.inc | If missing, create a .htaccess file in each Drupal files directory. |
| file_get_mimetype | includes/file.inc | Determine an Internet Media Type, or MIME type from a filename. |
| file_get_stream_wrappers | includes/file.inc | Drupal stream wrapper registry. |
| file_load | includes/file.inc | Load a file object from the database. |
| file_load_multiple | includes/file.inc | Load file objects from the database. |
| file_move | includes/file.inc | Move a file to a new location and update the file's database entry. |
| file_munge_filename | includes/file.inc | Modify a filename as needed for security purposes. |
| file_prepare_directory | includes/file.inc | Check that the directory exists and is writable. |
| file_save | includes/file.inc | Save a file object to the database. |
| file_save_data | includes/file.inc | Save a string to the specified destination and create a database file entry. |
| 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 | Determine 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 given scheme. |
| file_stream_wrapper_get_instance_by_uri | includes/file.inc | Returns a reference to the stream wrapper class responsible for a given URI (stream). |
| file_stream_wrapper_uri_normalize | includes/file.inc | Normalizes a URI by making it syntactically correct. |
| file_stream_wrapper_valid_scheme | includes/file.inc | Check that the scheme of a stream URI is valid. |
| file_transfer | includes/file.inc | Transfer file using HTTP to client. Pipes a file through Drupal to the client. |
| file_unmanaged_copy | includes/file.inc | Copy a file to a new location without calling any hooks or making any changes to the database. |
| file_unmanaged_delete | includes/file.inc | Delete a file without calling any hooks or making any changes to the database. |
| file_unmanaged_delete_recursive | includes/file.inc | Recursively delete all files and directories in the specified filepath. |
| file_unmanaged_move | includes/file.inc | Move a file to a new location without calling any hooks or making any changes to the database. |
| file_unmanaged_save_data | includes/file.inc | Save a string to the specified destination without calling any hooks or making any changes to the database. |
| file_unmunge_filename | includes/file.inc | Undo the effect of upload_munge_filename(). |
| file_upload_max_size | includes/file.inc | Determine 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 target of a URI (e.g. a stream). |
| file_validate | includes/file.inc | Check that a file meets the criteria specified by the validators. |
| file_validate_extensions | includes/file.inc | Check that the filename ends with an allowed extension. |
| file_validate_image_resolution | includes/file.inc | If the file is an image verify that its dimensions are within the specified maximum and minimum dimensions. |
| file_validate_is_image | includes/file.inc | Check that the file is recognized by image_get_info() as an image. |
| file_validate_name_length | includes/file.inc | Check for files with names longer than we can store in the database. |
| file_validate_size | includes/file.inc | Check that the file's size is below certain limits. |
