How can PHP 5.2 be utilized to enhance the file upload process and user interaction on a website?

PHP 5.2 can be utilized to enhance the file upload process and user interaction on a website by implementing features such as file size validation, file type checking, and displaying user-friendly error messages.

<?php
if ($_FILES['file']['size'] > 5000000) {
    echo "File size is too large. Please upload a file under 5MB.";
} elseif ($_FILES['file']['type'] != 'image/jpeg' && $_FILES['file']['type'] != 'image/png') {
    echo "Invalid file type. Please upload a JPEG or PNG file.";
} else {
    move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $_FILES['file']['name']);
    echo "File uploaded successfully!";
}
?>