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.
  • filepath - Path of the file relative to Drupal root.
  • 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 least sigifigant bit indicates temporary (1) or permanent (0). Temporary files older than DRUPAL_MAXIMUM_TEMP_FILE_AGE will be removed during a cron run.
  • timestamp - UNIX timestamp for the date the file was added to the database.

Constants

Namesort iconLocationDescription
FILE_CREATE_DIRECTORYdrupal/includes/file.incFlag used by file_check_directory() -- create directory if not present.
FILE_DOWNLOADS_PRIVATEdrupal/includes/file.incFlag to indicate that the 'private' file download method is enabled.
FILE_DOWNLOADS_PUBLICdrupal/includes/file.incFlag to indicate that the 'public' file download method is enabled.
FILE_EXISTS_ERRORdrupal/includes/file.incFlag for dealing with existing files: Do nothing and return FALSE.
FILE_EXISTS_RENAMEdrupal/includes/file.incFlag for dealing with existing files: Appends number until name is unique.
FILE_EXISTS_REPLACEdrupal/includes/file.incFlag for dealing with existing files: Replace the existing file.
FILE_MODIFY_PERMISSIONSdrupal/includes/file.incFlag used by file_check_directory() -- file permissions may be changed.
FILE_STATUS_PERMANENTdrupal/includes/file.incFile status -- File has been permanently saved to the {files} tables.
FILE_STATUS_TEMPORARYdrupal/includes/file.incFile status -- File has been temporarily saved to the {files} tables.

Functions

Namesort iconLocationDescription
file_check_directorydrupal/includes/file.incCheck that the directory exists and is writable.
file_check_locationdrupal/includes/file.incCheck if a file is really located inside $directory.
file_check_pathdrupal/includes/file.incChecks path to see if it is a directory, or a directory/file.
file_copydrupal/includes/file.incCopy a file to a new location and adds a file record to the database.
file_create_filenamedrupal/includes/file.incCreate a full file path from a directory and filename.
file_create_pathdrupal/includes/file.incMake 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_urldrupal/includes/file.incCreate the download path to a file.
file_deletedrupal/includes/file.incDelete a file and its database record.
file_destinationdrupal/includes/file.incDetermines the destination path for a file depending on how replacement of existing files should be handled.
file_directory_pathdrupal/includes/file.incDetermine the default 'files' directory.
file_directory_tempdrupal/includes/file.incDetermine the default temporary directory.
file_downloaddrupal/includes/file.incMenu handler for private file transfers.
file_get_mimetypedrupal/includes/file.incDetermine an Internet Media Type, or MIME type from a filename.
file_loaddrupal/includes/file.incLoad a file object from the database.
file_movedrupal/includes/file.incMove a file to a new location and update the file's database entry.
file_munge_filenamedrupal/includes/file.incMunge the filename as needed for security purposes.
file_savedrupal/includes/file.incSave a file object to the database.
file_save_datadrupal/includes/file.incSave a string to the specified destination and create a database file entry.
file_save_uploaddrupal/includes/file.incSaves a file upload to a new location.
file_scan_directorydrupal/includes/file.incFinds all files that match a given mask in a given directory.
file_space_useddrupal/includes/file.incDetermine total disk space used by a single user or the whole filesystem.
file_transferdrupal/includes/file.incTransfer file using HTTP to client. Pipes a file through Drupal to the client.
file_unmanaged_copydrupal/includes/file.incCopy a file to a new location without calling any hooks or making any changes to the database.
file_unmanaged_deletedrupal/includes/file.incDelete a file without calling any hooks or making any changes to the database.
file_unmanaged_movedrupal/includes/file.incMove a file to a new location without calling any hooks or making any changes to the database.
file_unmanaged_save_datadrupal/includes/file.incSave a string to the specified destination without calling any hooks or making any changes to the database.
file_unmunge_filenamedrupal/includes/file.incUndo the effect of upload_munge_filename().
file_upload_max_sizedrupal/includes/file.incDetermine the maximum file upload size by querying the PHP settings.
file_validatedrupal/includes/file.incCheck that a file meets the criteria specified by the validators.
file_validate_extensionsdrupal/includes/file.incCheck that the filename ends with an allowed extension.
file_validate_image_resolutiondrupal/includes/file.incIf the file is an image verify that its dimensions are within the specified maximum and minimum dimensions.
file_validate_is_imagedrupal/includes/file.incCheck that the file is recognized by image_get_info() as an image.
file_validate_name_lengthdrupal/includes/file.incCheck for files with names longer than we can store in the database.
file_validate_sizedrupal/includes/file.incCheck that the file's size is below certain limits.