| 4.7 file.inc | file_directory_path() |
| 5 file.inc | file_directory_path() |
| 6 file.inc | file_directory_path() |
Determine the default 'files' directory.
Return value
A string containing the path to Drupal's 'files' directory.
Related topics
14 calls to file_directory_path()
- color_scheme_form_submit in modules/
color/ color.module - Submit handler for color change form.
- drupal_get_css in includes/
common.inc - Returns a themed representation of all stylesheets that should be attached to the page.
- drupal_get_js in includes/
common.inc - Returns a themed presentation of all JavaScript code for the current page.
- file_check_directory in includes/
file.inc - Checks whether a directory exists and is writable.
- file_create_path in includes/
file.inc - Make sure the destination is a complete path and resides in the file system directory, if it is not prepend the file system directory.
3 string references to 'file_directory_path'
- system_file_system_settings in modules/
system/ system.admin.inc - Form builder; Configure the site file handling.
- system_theme_settings in modules/
system/ system.admin.inc - Form builder; display theme configuration for entire site and individual themes.
- system_update_6046 in modules/
system/ system.install - Ensure that the file_directory_path variable is set (using the old 5.x default, if necessary), so that the changed 6.x default won't break existing sites.
File
- includes/
file.inc, line 1041 - API for handling file uploads and server file management.
Code
function file_directory_path() {
return variable_get('file_directory_path', conf_path() . '/files');
}
Comments
removed in 7.x
Permalinkfile_directory_path has been removed in 7.x.
Instead, use:
<?phpfile_default_scheme() . ':/'
?>
see http://drupal.org/update/modules/6/7#file_directory_path
Drupal 7 way
PermalinkYou can try this:
drupal_realpath('public://')More sensible
PermalinkWell,
file_default_scheme()seems to be more sensible, as it returns 'public' or 'private' according to the value set in file_default_scheme variable.Re: More sensible
PermalinkIf you want the relative path in D7 (same as file_directory_path() in D6) use:
variable_get('file_' . file_default_scheme() . '_path', conf_path() . '/files');
If you want the absolute path in D7 use:
drupal_realpath(file_default_scheme() . '://');
In D6, file_directory_path() returns the relative path.
Wonderful! Thanks-- I wish
PermalinkWonderful!
Thanks-- I wish D7 had left in file_directory_path(), and just marked it as "deprecated" or some such.
This returns the path
PermalinkThis returns the path relative to the Drupal root folder, eg 'sites/default/files'.
You mean that
PermalinkYou mean that file_directory_path returned that in D6? No one has posted a way to do the same thing!
<?php
Permalink<?phpvariable_get('file_public_path', conf_path() . '/files')
?>
The full filesystem path to
PermalinkThe full filesystem path to the files folder:
$_SERVER['DOCUMENT_ROOT'] . base_path() . file_directory_path()FYI: This breaks for private
PermalinkFYI: This breaks for private filesystems.
The best I've sorted is something like this:
<?phpif(variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE){
$path = file_directory_path();
} else {
$path = $_SERVER['DOCUMENT_ROOT'] . base_path() . file_directory_path();
}
?>
This works for both public and private files given a URI
Permalinkfunction file_realpath($uri) {$scheme = file_uri_scheme($uri);
$wrapper = file_stream_wrapper_get_instance_by_scheme($scheme);
return $_SERVER['DOCUMENT_ROOT'] . '/' . $wrapper->getDirectoryPath() . '/' . file_uri_target($uri);
}