What are the potential security risks of relying solely on client-side validation for file uploads in PHP?

Relying solely on client-side validation for file uploads in PHP can be risky as it can be easily bypassed by malicious users. To mitigate this risk, server-side validation should also be implemented to ensure that only safe and allowed file types are uploaded.

// Server-side validation for file uploads
if(isset($_FILES['file'])) {
    $file_name = $_FILES['file']['name'];
    $file_tmp = $_FILES['file']['tmp_name'];
    $file_type = $_FILES['file']['type'];
    
    $allowed_types = array('image/jpeg', 'image/png', 'image/gif');
    
    if(!in_array($file_type, $allowed_types)) {
        echo "Error: Only JPEG, PNG, and GIF files are allowed.";
    } else {
        move_uploaded_file($file_tmp, "uploads/" . $file_name);
        echo "File uploaded successfully.";
    }
}