File interface

  1. drupal
    1. drupal6
    2. drupal7

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 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.

Funktionen & Methoden

NameBeschreibung
drupal_chmodSet the permissions on a file or directory.
file_check_directoryCheck that the directory exists and is writable.
file_check_locationCheck if a file is really located inside $directory.
file_check_pathChecks path to see if it is a directory, or a directory/file.
file_copyCopy a file to a new location and adds a file record to the database.
file_create_filenameCreate a full file path from a directory and filename.
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 and its database record.
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_downloadMenu handler for private file transfers.
file_get_mimetypeDetermine an Internet Media Type, or MIME type from a filename.
file_loadLoad a file object from the database.
file_load_multipleLoad file objects from the database.
file_moveMove a file to a new location and update the file's database entry.
file_munge_filenameMunge the filename as needed for security purposes.
file_saveSave a file object to the database.
file_save_dataSave a string to the specified destination and create a database file entry.
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_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_unmanaged_copyCopy a file to a new location without calling any hooks or making any changes to the database.
file_unmanaged_deleteDelete a file without calling any hooks or making any changes to the database.
file_unmanaged_delete_recursiveRecursively delete all files and directories in the specified filepath.
file_unmanaged_moveMove a file to a new location without calling any hooks or making any changes to the database.
file_unmanaged_save_dataSave a string to the specified destination without calling any hooks or making any changes to the database.
file_unmunge_filenameUndo the effect of upload_munge_filename().
file_upload_max_sizeDetermine the maximum file upload size by querying the PHP settings.
file_validateCheck that a file meets the criteria specified by the validators.
file_validate_extensionsCheck that the filename ends with an allowed extension.
file_validate_image_resolutionIf the file is an image verify that its dimensions are within the specified maximum and minimum dimensions.
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.

Konstanten

NameBeschreibung
FILE_CREATE_DIRECTORYFlag used by file_check_directory() -- create directory if not present.
FILE_DOWNLOADS_PRIVATEFlag to indicate that the 'private' file download method is enabled.
FILE_DOWNLOADS_PUBLICFlag to indicate that the 'public' file download method is enabled.
FILE_EXISTS_ERRORFlag for dealing with existing files: Do nothing and return FALSE.
FILE_EXISTS_RENAMEFlag for dealing with existing files: Appends number until name is unique.
FILE_EXISTS_REPLACEFlag for dealing with existing files: Replace the existing file.
FILE_MODIFY_PERMISSIONSFlag used by file_check_directory() -- file permissions may be changed.
FILE_STATUS_PERMANENTFile 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.

includes/file.inc, line 9

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen