How can PHP be used to create a file upload feature that can upload multiple scripts at once?

To create a file upload feature in PHP that allows users to upload multiple files at once, you can use the HTML input element with the "multiple" attribute set to allow multiple file selection. In the PHP script handling the form submission, you can loop through the $_FILES array to process each uploaded file individually.

<form action="upload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="files[]" multiple>
    <input type="submit" value="Upload">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $fileCount = count($_FILES['files']['name']);
    for ($i = 0; $i < $fileCount; $i++) {
        $fileName = $_FILES['files']['name'][$i];
        $fileTmpName = $_FILES['files']['tmp_name'][$i];
        move_uploaded_file($fileTmpName, "uploads/" . $fileName);
        echo "File uploaded: " . $fileName . "<br>";
    }
}
?>