The following code will return the root path for a drupal file system.
Sample code:
$path = \Drupal::service('file_system')->realpath(file_default_scheme() . "://") . '/');
print_r(“PATH : ”$path);
Output:
/var/www/html/directory_site_x/sites/default/files/