What are the potential issues or security risks of creating a new folder using PHP mkdir function?

One potential security risk of creating a new folder using the PHP mkdir function is that it may allow for directory traversal attacks if the folder name is not properly sanitized. To mitigate this risk, always sanitize user input before using it in the mkdir function to prevent malicious users from creating folders in unintended directories.

// Sanitize user input before creating a new folder
$folderName = filter_var($_POST['folder_name'], FILTER_SANITIZE_STRING);

// Create a new folder using the sanitized input
mkdir('/path/to/parent/directory/' . $folderName, 0777);