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 comment

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