PHP Multiple File Upload Example

Apr 15, 2021 . Admin

Hi Guys,

In this blog, I’ll explain the basics of multiple file upload in PHP.

In PHP, it is possible to upload multiple files utilizing a single input file element. You just need to customize your single file upload PHP code and enable your file element to cull multiple files.

Before we started are some steps to enable multiple files uploads in <form>.

First, create a <form> and add enctype='multiple/form-data' attribute.

Create an input type='file' element and for enabling multiple files selection add multiple attribute. For reading all selected files when <form> submitted add [] brackets at the end of a name which denotes an Array.

In this example i use following files for html and php that way we can make simple example:

Ok, now you can see below example source code and also check demo goes on upload an file and then click submit button file uploaded own directory.

First we created... Step:1 multiple_file.php
<!DOCTYPE html>
<html lang="en">
    PHP Multiple File Upload Example -

PHP Multiple File Upload

</body> </html>

And now another backend file created store image in your directory Step:2 multiple_file_upload.php


         // Count total files
         $count_files = count($_FILES['file']['name']);
         // Looping all files
          $filename = $_FILES['file']['name'][$i];
          // Upload file


It will help you..