Drupal File Operation

This post will illustrate various handy file operations available in Drupal

Get Absolute Path of a file from URI : drupal_realpath()
A URI in drupal looks like: private://donor_registration/somefile.csv for a private file
Absolute Path: /srv/www/example.com/public_html/sites/default/private/files/donor_registration/somefile.csv

<?php
  $absolute_path
= drupal_realpath($uri);
 
drupal_set_message(t("Realpath is: $absolute_path"), 'status', FALSE);
?>

--
Sources:
https://api.drupal.org/api/drupal/includes!file.inc/function/drupal_real...