What are the limitations of using the "accept" attribute in HTML for restricting file types in PHP forms?

The "accept" attribute in HTML can be easily bypassed by users who know how to manipulate the file selection dialog. To enforce stricter file type restrictions, you should validate the file type on the server-side using PHP. You can do this by checking the file extension or MIME type of the uploaded file.

<?php
$allowed_file_types = array('image/jpeg', 'image/png', 'image/gif');
$uploaded_file_type = $_FILES['file']['type'];

if (!in_array($uploaded_file_type, $allowed_file_types)) {
    echo "Invalid file type. Please upload a JPEG, PNG, or GIF file.";
    exit;
}

// Continue processing the uploaded file