Enumerations | |
enum | FILE_DOWNLOADS_PUBLIC |
enum | FILE_DOWNLOADS_PRIVATE |
enum | FILE_CREATE_DIRECTORY |
enum | FILE_MODIFY_PERMISSIONS |
enum | FILE_EXISTS_RENAME |
enum | FILE_EXISTS_REPLACE |
enum | FILE_EXISTS_ERROR |
enum | FILE_STATUS_TEMPORARY |
enum | FILE_STATUS_PERMANENT |
Functions | |
file_create_url ($path) | |
file_create_path ($dest=0) | |
file_check_directory (&$directory, $mode=0, $form_item=NULL) | |
file_check_path (&$path) | |
file_check_location ($source, $directory= '') | |
file_copy (&$source, $dest=0, $replace=FILE_EXISTS_RENAME) | |
file_destination ($destination, $replace) | |
file_move (&$source, $dest=0, $replace=FILE_EXISTS_RENAME) | |
file_munge_filename ($filename, $extensions, $alerts=TRUE) | |
file_unmunge_filename ($filename) | |
file_create_filename ($basename, $directory) | |
file_delete ($path) | |
file_space_used ($uid=NULL) | |
file_save_upload ($source, $validators=array(), $dest=FALSE, $replace=FILE_EXISTS_RENAME) | |
file_validate_name_length ($file) | |
file_validate_extensions ($file, $extensions) | |
file_validate_size ($file, $file_limit=0, $user_limit=0) | |
file_validate_is_image (&$file) | |
file_validate_image_resolution (&$file, $maximum_dimensions=0, $minimum_dimensions=0) | |
file_save_data ($data, $dest, $replace=FILE_EXISTS_RENAME) | |
file_set_status (&$file, $status) | |
file_transfer ($source, $headers) | |
file_download () | |
file_scan_directory ($dir, $mask, $nomask=array('.', '..', 'CVS'), $callback=0, $recurse=TRUE, $key= 'filename', $min_depth=0, $depth=0) | |
file_directory_temp () | |
file_directory_path () | |
file_upload_max_size () |
enum FILE_EXISTS_ERROR |
enum FILE_EXISTS_RENAME |
enum FILE_EXISTS_REPLACE |
file_check_directory | ( | &$ | directory, | |
$ | mode = 0 , |
|||
$ | form_item = NULL | |||
) |
Check that the directory exists and is writable. Directories need to have execute permissions to be considered a directory by FTP servers, etc.
$directory | A string containing the name of a directory path. | |
$mode | A Boolean value to indicate if the directory should be created if it does not exist or made writable if it is read-only. | |
$form_item | An optional string containing the name of a form item that any errors will be attached to. This is useful for settings forms that require the user to specify a writable directory. If it can't be made to work, a form error will be set preventing them from saving the settings. |
Definition at line 136 of file file.inc.
References check_plain(), drupal_set_message(), file_directory_path(), file_directory_temp(), form_set_error(), t(), and watchdog().
Referenced by _locale_rebuild_js(), drupal_build_css_cache(), drupal_build_js_cache(), file_check_path(), DrupalWebTestCase::setUp(), system_theme_settings(), and user_admin_settings().
file_check_location | ( | $ | source, | |
$ | directory = '' | |||
) |
Check 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.
// Returns FALSE: file_check_location('/www/example.com/files/../../../etc/passwd', '/www/example.com/files');
$source | A string set to the file to check. | |
$directory | A string where the file should be located. |
Definition at line 219 of file file.inc.
Referenced by file_create_path().
file_check_path | ( | &$ | path | ) |
Checks path to see if it is a directory, or a dir/file.
$path | A string containing a file path. This will be set to the directory's path. |
Definition at line 189 of file file.inc.
References file_check_directory().
Referenced by file_copy(), and file_save_upload().
file_copy | ( | &$ | source, | |
$ | dest = 0 , |
|||
$ | replace = FILE_EXISTS_RENAME | |||
) |
Copies a file to a new location. This is a powerful function that in many ways performs like an advanced version of copy().
$source | A string specifying the file location of the original file. This parameter will contain the resulting destination filename in case of success. | |
$dest | A string containing the directory $source should be copied to. If this value is omitted, Drupal's 'files' directory will be used. | |
$replace | Replace behavior when the destination file already exists.
|
Definition at line 254 of file file.inc.
References drupal_set_message(), file_check_path(), file_create_path(), file_destination(), t(), and watchdog().
Referenced by file_move(), and system_theme_settings().
file_create_filename | ( | $ | basename, | |
$ | directory | |||
) |
Create a full file path from a directory and filename. If a file with the specified name already exists, an alternative will be used.
$basename | string filename | |
$directory | string directory |
Definition at line 443 of file file.inc.
References $name.
Referenced by file_destination().
file_create_path | ( | $ | dest = 0 |
) |
Make sure the destination is a complete path and resides in the file system directory, if it is not prepend the file system directory.
$dest | A string containing the path to verify. If this value is omitted, Drupal's 'files' directory will be used. |
Definition at line 102 of file file.inc.
References file_check_location(), file_directory_path(), and file_directory_temp().
Referenced by _locale_rebuild_js(), drupal_build_css_cache(), drupal_build_js_cache(), drupal_clear_css_cache(), drupal_clear_js_cache(), file_copy(), file_download(), file_save_upload(), file_transfer(), and user_admin_settings().
file_create_url | ( | $ | path | ) |
Create the download path to a file.
$path | A string containing the path of the file to generate URL for. |
Definition at line 79 of file file.inc.
References file_directory_path(), url(), and variable_get().
file_delete | ( | $ | path | ) |
Delete a file.
$path | A string containing a file path. |
Definition at line 471 of file file.inc.
Referenced by _locale_rebuild_js(), and file_move().
file_destination | ( | $ | destination, | |
$ | replace | |||
) |
Determines the destination path for a file depending on how replacement of existing files should be handled.
$destination | A string specifying the desired path. | |
$replace | Replace behavior when the destination file already exists.
|
Definition at line 333 of file file.inc.
References drupal_set_message(), file_create_filename(), and t().
Referenced by file_copy(), and file_save_upload().
file_directory_path | ( | ) |
Determine the default 'files' directory.
Definition at line 999 of file file.inc.
References conf_path(), and variable_get().
Referenced by drupal_get_css(), drupal_get_js(), file_check_directory(), file_create_path(), file_create_url(), file_directory_temp(), DrupalWebTestCase::setUp(), system_file_system_settings(), system_performance_settings(), system_theme_settings(), DrupalWebTestCase::tearDown(), and user_admin_settings().
file_directory_temp | ( | ) |
Determine the default temporary directory.
Definition at line 958 of file file.inc.
References file_directory_path(), variable_get(), and variable_set().
Referenced by file_check_directory(), file_create_path(), file_save_data(), file_save_upload(), and system_file_system_settings().
file_download | ( | ) |
Call 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 will start with the returned headers. If no modules respond drupal_not_found() will be returned.
Definition at line 865 of file file.inc.
References drupal_access_denied(), drupal_not_found(), file_create_path(), file_transfer(), and module_invoke_all().
file_move | ( | &$ | source, | |
$ | dest = 0 , |
|||
$ | replace = FILE_EXISTS_RENAME | |||
) |
Moves a file to a new location.
$source | A string specifying the file location of the original file. This parameter will contain the resulting destination filename in case of success. | |
$dest | A string containing the directory $source should be copied to. If this value is omitted, Drupal's 'files' directory will be used. | |
$replace | Replace behavior when the destination file already exists.
|
Definition at line 368 of file file.inc.
References drupal_set_message(), file_copy(), file_delete(), and t().
Referenced by file_save_data().
file_munge_filename | ( | $ | filename, | |
$ | extensions, | |||
$ | alerts = TRUE | |||
) |
Munge the filename as needed for security purposes. For instance the file name "exploit.php.pps" would become "exploit.php_.pps".
$filename | The name of a file to modify. | |
$extensions | A space separated list of extensions that should not be altered. | |
$alerts | Whether alerts (watchdog, drupal_set_message()) should be displayed. |
Definition at line 393 of file file.inc.
References drupal_set_message(), t(), and variable_get().
Referenced by file_save_upload().
file_save_data | ( | $ | data, | |
$ | dest, | |||
$ | replace = FILE_EXISTS_RENAME | |||
) |
Save a string to the specified destination.
$data | A string containing the contents of the file. | |
$dest | A string containing the destination location. | |
$replace | Replace behavior when the destination file already exists.
|
Definition at line 791 of file file.inc.
References drupal_set_message(), file_directory_temp(), file_move(), and t().
Referenced by _locale_rebuild_js(), drupal_build_css_cache(), and drupal_build_js_cache().
file_save_upload | ( | $ | source, | |
$ | validators = array() , |
|||
$ | dest = FALSE , |
|||
$ | replace = FILE_EXISTS_RENAME | |||
) |
Saves a file upload to a new location. The source file is validated as a proper upload and handled as such.
The file will be added to the files table as a temporary file. Temporary files are periodically cleaned. To make the file permanent file call file_set_status() to change its status.
$source | A string specifying the name of the upload field to save. | |
$validators | An optional, associative array of callback functions used to validate the file. The keys are function names and the values arrays of callback parameters which will be passed in after the user and file objects. The functions should return an array of error messages, an empty array indicates that the file passed validation. The functions will be called in the order specified. | |
$dest | A string containing the directory $source should be copied to. If this is not provided or is not writable, the temporary directory will be used. | |
$replace | A boolean indicating whether an existing file of the same name in the destination directory should overwritten. A false value will generate a new, unique filename in the destination directory. |
Definition at line 518 of file file.inc.
References $name, drupal_set_message(), drupal_write_record(), file_check_path(), file_create_path(), file_destination(), file_directory_temp(), file_munge_filename(), file_upload_max_size(), form_set_error(), format_size(), t(), variable_get(), and watchdog().
Referenced by locale_translate_import_form_submit(), and system_theme_settings().
file_scan_directory | ( | $ | dir, | |
$ | mask, | |||
$ | nomask = array('.', '..', 'CVS') , |
|||
$ | callback = 0 , |
|||
$ | recurse = TRUE , |
|||
$ | key = 'filename' , |
|||
$ | min_depth = 0 , |
|||
$ | depth = 0 | |||
) |
Finds all files that match a given mask in a given directory. Directories and files beginning with a period are excluded; this prevents hidden files and directories (such as SVN working directories) from being scanned.
$dir | The base directory for the scan, without trailing slash. | |
$mask | The regular expression of the files to find. | |
$nomask | An array of files/directories to ignore. | |
$callback | The callback function to call for each match. | |
$recurse | When TRUE, the directory scan will recurse the entire tree starting at the provided directory. | |
$key | The key to be used for the returned array of files. Possible values are "filename", for the path starting with $dir, "basename", for the basename of the file, and "name" for the name of the file without an extension. | |
$min_depth | Minimum depth of directories to return files from. | |
$depth | Current depth of recursion. This parameter is only used internally and should not be passed. |
Definition at line 920 of file file.inc.
Referenced by _drupal_rebuild_code_registry(), drupal_clear_css_cache(), drupal_clear_js_cache(), drupal_system_listing(), DrupalWebTestCase::drupalGetTestFiles(), DrupalTests::getFiles(), image_get_available_toolkits(), install_find_locales(), install_find_profiles(), locale_batch_by_component(), and locale_batch_by_language().
file_set_status | ( | &$ | file, | |
$ | status | |||
) |
Set the status of a file.
file | A Drupal file object | |
status | A status value to set the file to. |
Definition at line 817 of file file.inc.
References $status, and db_query().
file_space_used | ( | $ | uid = NULL |
) |
Determine total disk space used by a single user or the whole filesystem.
$uid | An optional user id. A NULL value returns the total space used by all files. |
Definition at line 484 of file file.inc.
References db_query(), and db_result().
Referenced by file_validate_size().
file_transfer | ( | $ | source, | |
$ | headers | |||
) |
Transfer file using http to client. Pipes a file through Drupal to the client.
$source | File to transfer. | |
$headers | An array of http headers to send along with file. |
Definition at line 832 of file file.inc.
References $header, drupal_not_found(), drupal_set_header(), exit, file_create_path(), and print.
Referenced by file_download().
file_unmunge_filename | ( | $ | filename | ) |
file_upload_max_size | ( | ) |
Determine the maximum file upload size by querying the PHP settings.
Definition at line 1009 of file file.inc.
References parse_size().
Referenced by file_save_upload(), upload_admin_settings(), and upload_admin_settings_validate().
file_validate_extensions | ( | $ | file, | |
$ | extensions | |||
) |
Check that the filename ends with an allowed extension. This check is not enforced for the user #1.
$file | A Drupal file object. | |
$extensions | A string with a space separated |
Definition at line 657 of file file.inc.
References t().
file_validate_image_resolution | ( | &$ | file, | |
$ | maximum_dimensions = 0 , |
|||
$ | minimum_dimensions = 0 | |||
) |
If the file is an image verify that its dimensions are within the specified maximum and minimum dimensions. Non-image files will be ignored.
$file | A Drupal file object. This function may resize the file affecting its size. | |
$maximum_dimensions | An optional string in the form WIDTHxHEIGHT e.g. '640x480' or '85x85'. If an image toolkit is installed the image will be resized down to these dimensions. A value of 0 indicates no restriction on size, so resizing will be attempted. | |
$minimum_dimensions | An optional string in the form WIDTHxHEIGHT. This will check that the image meets a minimum size. A value of 0 indicates no restriction. |
Definition at line 743 of file file.inc.
References drupal_set_message(), image_get_info(), image_get_toolkit(), image_scale(), and t().
file_validate_is_image | ( | &$ | file | ) |
Check that the file is recognized by image_get_info() as an image.
$file | A Drupal file object. |
Definition at line 714 of file file.inc.
References image_get_info(), and t().
file_validate_name_length | ( | $ | file | ) |
file_validate_size | ( | $ | file, | |
$ | file_limit = 0 , |
|||
$ | user_limit = 0 | |||
) |
Check that the file's size is below certain limits. This check is not enforced for the user #1.
$file | A Drupal file object. | |
$file_limit | An integer specifying the maximum file size in bytes. Zero indicates that no limit should be enforced. | |
$$user_limit | An integer specifying the maximum number of bytes the user is allowed. Zero indicates that no limit should be enforced. |
Definition at line 687 of file file.inc.
References file_space_used(), format_size(), and t().