Is it possible to save multiple files at once using input type="file" in PHP?

When using input type="file" in PHP, it is not possible to save multiple files at once using a single input field. However, you can use multiple input fields with the same name attribute to allow users to select and upload multiple files simultaneously. You can then loop through the uploaded files array in PHP to save each file individually.

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

<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
    $files = $_FILES['files'];
    
    foreach($files['tmp_name'] as $key => $tmp_name){
        $file_name = $files['name'][$key];
        $file_tmp = $files['tmp_name'][$key];
        
        move_uploaded_file($file_tmp, "uploads/" . $file_name);
    }
}
?>