$file = '/var/www/html/index.php'; if (GeneralUtility::isAllowedAbsPath($file)) { // Do something with the file } else { // File path is not allowed }
$dir = '/var/www/html/uploads/'; if (GeneralUtility::isAllowedAbsPath($dir, true)) { // Do something with the directory } else { // Directory path is not allowed }In these examples, `isAllowedAbsPath()` is used to check if the given path is within the allowed paths for the TYPO3 installation. The second parameter in the function call is optional and specifies whether the path is a directory (`true`) or a file (`false`, or omitted). The package library for `GeneralUtility` is `TYPO3\CMS\Core\Utility`.