What is the correct way to retrieve the file path from a form submission in PHP?

When a file is submitted through a form in PHP, the file path is not directly accessible through $_POST or $_GET superglobals. Instead, the file information is stored in the $_FILES superglobal array. To retrieve the file path, you need to access the 'tmp_name' key of the $_FILES array for the uploaded file.

// Retrieve the file path from a form submission in PHP
if(isset($_FILES['file']['tmp_name'])) {
    $file_path = $_FILES['file']['tmp_name'];
    echo "File path: " . $file_path;
} else {
    echo "No file uploaded.";
}