Drupal 7 Get Default Files Directory Path

While working on Drupal coding, sometimes you may want to get the default files directory path. Here it is said as 'default' intentionally, as you can configure a Drupal installation to have default directory as public or private. For most of the sites it will public files directory.

Use following code snippet to get default files directory path.

drupal_realpath(file_default_scheme() . '://');

Or, if you want to get public or private files directory path specifically. Then you can use this to get public directory.

drupal_realpath('public://');

Or, for private directory path.

drupal_realpath('private://');