What is the best way to display a message or image indicating that a file is being uploaded in PHP?

When uploading a file in PHP, it's important to provide visual feedback to the user to indicate that the file is being uploaded. One common way to do this is by displaying a loading spinner or progress bar while the file is being processed. This can help prevent the user from becoming confused or frustrated if the upload process takes a while.

<!DOCTYPE html>
<html>
<head>
    <title>File Upload</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $(document).ready(function(){
            $('#uploadForm').submit(function(){
                $('#uploadStatus').html('Uploading file... <img src="loading.gif" />');
            });
        });
    </script>
</head>
<body>
    <form id="uploadForm" action="upload.php" method="post" enctype="multipart/form-data">
        <input type="file" name="file">
        <input type="submit" value="Upload">
    </form>
    <div id="uploadStatus"></div>
</body>
</html>