File interface

  1. drupal
    1. 5
    2. 6
    3. 7
    4. 8

Common file handling functions.

Functions & methods

file_check_directoryChecks whether a directory exists and is writable.
file_check_locationCheck 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_pathChecks path to see if it is a directory, or a dir/file.
file_copyCopies a file to a new location.
file_create_filenameCreate 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_pathMake 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_urlCreate the download path to a file.
file_deleteDelete a file.
file_destinationDetermines the destination path for a file depending on how replacement of existing files should be handled.
file_directory_pathDetermine the default 'files' directory.
file_directory_tempDetermine the default temporary directory.
file_downloadCall modules that implement hook_file_download() to find out if a file is accessible and what headers it should be transferred with. If a module returns -1 drupal_access_denied() will be returned. If one or more modules returned headers the download…
file_get_mimetypeDetermine an Internet Media Type, or MIME type from a filename.
file_moveMoves a file to a new location.
file_munge_filenameModify a filename as needed for security purposes.
file_save_dataSave a string to the specified destination.
file_save_uploadSaves a file upload to a new location.
file_scan_directoryFinds all files that match a given mask in a given directory.
file_set_statusSet the status of a file.
file_space_usedDetermine total disk space used by a single user or the whole filesystem.
file_transferTransfer file using http to client. Pipes a file through Drupal to the client.
file_unmunge_filenameUndo the effect of upload_munge_filename().
file_upload_max_sizeDetermine the maximum file upload size by querying the PHP settings.
file_validate_extensionsCheck that the filename ends with an allowed extension. This check is not enforced for the user #1.
file_validate_image_resolutionIf the file is an image verify that its dimensions are within the specified maximum and minimum dimensions. Non-image files will be ignored.
file_validate_is_imageCheck that the file is recognized by image_get_info() as an image.
file_validate_name_lengthCheck for files with names longer than we can store in the database.
file_validate_sizeCheck that the file's size is below certain limits. This check is not enforced for the user #1.


FILE_STATUS_TEMPORARYA files status can be one of two values: temporary or permanent. The status for each file Drupal manages is stored in the {files} tables. If the status is temporary Drupal's file garbage collection will delete the file and remove it from the…

includes/, line 8