How can PHP be used to differentiate between displaying form data and linking to an uploaded file?

To differentiate between displaying form data and linking to an uploaded file in PHP, you can check if the form field contains text or a file path. If the form field contains text, you can display the data. If it contains a file path, you can create a link to the uploaded file.

<?php
if(isset($_POST['form_field'])){
    $data = $_POST['form_field'];
    
    if(file_exists($data)){
        echo '<a href="'.$data.'">Download File</a>';
    } else {
        echo 'Form Data: ' . $data;
    }
}
?>