Drupal 7 – Get the relative and absolute public file path

Previously we talked about how to get the absolute file path of your Drupal installation.
Drupal – Get the absolute file path of your Drupal installation

There are also other ways to get different file paths in Drupal. Suppose the Drupal webroot path is /var/www/drupal.

print variable_get('file_public_path', conf_path() . '/files');
// output: sites/default/files 

print drupal_realpath(file_default_scheme() . '://');
// output: /var/www/drupal/sites/default/files

print realpath(".");
// output: /var/www/drupal

 

Done =)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.