What are some best practices for implementing a feature that shows if a user is uploading files in PHP?

One best practice for implementing a feature that shows if a user is uploading files in PHP is to use AJAX to periodically check the status of the upload and display it to the user in real-time. This can be achieved by sending requests to a PHP script that checks the progress of the upload and returns the status.

// HTML form for file upload
<form action="upload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="file">
    <input type="submit" value="Upload">
</form>

// JavaScript code to periodically check upload status
<script>
    setInterval(function() {
        $.ajax({
            url: 'check_upload_status.php',
            success: function(response) {
                // Display upload status to user
            }
        });
    }, 1000); // Check every second
</script>

// PHP script to check upload status
<?php
// Code to check upload status and return it
?>