How can I ensure that the file path displayed in a type="file" field in a PHP form is secure and user-friendly?

When displaying a file path in a type="file" field in a PHP form, you can ensure security by not displaying the full file path on the client side to prevent potential security risks. Instead, you can display just the file name to make it more user-friendly. This can be achieved by using PHP to extract the file name from the full file path before displaying it in the form.

<?php
// Get the file name from the full file path
$fullFilePath = $_FILES['file']['name'];
$fileName = pathinfo($fullFilePath, PATHINFO_FILENAME);

// Display the file name in the input field
echo '<input type="file" name="file" value="' . $fileName . '">';
?>