Why drupal_realpath('public://') returns an incorrect path? As in questions. I am calling drupal_realpath('public://') inside module function. I have no idea why I am getting path like: sites/all/modules/current_module/sites/default/files, e.g.


  C:\drupal_path\sites\all\modules[current_module]\sites\default\files
drupal_realpath() has been deprecated and shouldn't be used; since you have a stream wrapper URI you should be able to get the correct path like this:

$uri = 'public://';
if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
  $path = $wrapper-&gt;realpath();
}


Also make sure that your public path is correct in the UI (at admin/config/media/file-system)