$file = 'file.txt'; $absFile = t3lib_div::getFileAbsFileName($file); // $absFile will be: /var/www/example.com/public_html/file.txt in Unix or C:\xampp\htdocs\example.com\public_html\file.txt in Windows
$file = '../data/file.txt'; $absFile = t3lib_div::getFileAbsFileName($file, $rootPath); // $absFile will be: /var/www/example.com/data/file.txt in Unix or C:\xampp\htdocs\example.com\data\file.txt in Windows, assuming $rootPath is '/var/www/example.com/public_html' in Unix or 'C:\xampp\htdocs\example.com\public_html' in WindowsThis example takes a relative file path (`../data/file.txt`) and a root directory path `$rootPath`. The `getFileAbsFileName` function concatenates these two paths to get the absolute file path (`/var/www/example.com/data/file.txt` or `C:\xampp\htdocs\example.com\data\file.txt`, depending on the server operating system). The `t3lib_div` library is part of the TYPO3 CMS package.