4.7.x file.inc file_directory_path()
5.x file.inc file_directory_path()
6.x file.inc file_directory_path()

Determine the default 'files' directory.

Return value

A string containing the path to Drupal's 'files' directory.

Related topics

13 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_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.
file_create_url in includes/file.inc
Create the download path to a file.

... See full list

2 string references to 'file_directory_path'
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.


includes/file.inc, line 1153
API for handling file uploads and server file management.


function file_directory_path() {
  return variable_get('file_directory_path', conf_path() . '/files');


grendzy’s picture

file_directory_path has been removed in 7.x.

Instead, use:

file_default_scheme() . ':/' 

see http://drupal.org/update/modules/6/7#file_directory_path

foripepe’s picture

You can try this:

sanduhrs’s picture

Well, file_default_scheme() seems to be more sensible, as it returns 'public' or 'private' according to the value set in file_default_scheme variable.

uberhacker’s picture

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

richardp’s picture


Thanks-- I wish D7 had left in file_directory_path(), and just marked it as "deprecated" or some such.

pfrenssen’s picture

This returns the path relative to the Drupal root folder, eg 'sites/default/files'.

1kenthomas’s picture

You mean that file_directory_path returned that in D6? No one has posted a way to do the same thing!

Andreas@drupal’s picture

  variable_get('file_public_path', conf_path() . '/files') 
This gives you exactly the same as file_directory_path() in D6.
pfrenssen’s picture

The full filesystem path to the files folder:
$_SERVER['DOCUMENT_ROOT'] . base_path() . file_directory_path()

jonathangreen’s picture

FYI: This breaks for private filesystems.

The best I've sorted is something like this:

if(variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE){
  $path = file_directory_path();
} else {
  $path = $_SERVER['DOCUMENT_ROOT'] . base_path() . file_directory_path();
scott.whittaker’s picture

function 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);
kenorb’s picture

Use this instead: file_stream_wrapper_get_instance_by_scheme(file_default_scheme())->getDirectoryPath()