You’ll need to add brackets to the name
of your multiple input form element for PHP to interpret it as an array.
<input type="file" multiple name="thumbnail[]" id="thumbnail">
You’ll then get an array named ‘thumbnail’ with 5 arrays within it. See this comment on php.net for a breakdown of the structure.
Edit: Notice the difference in what is returned for a single vs a multiple file input. Here’s an example with two form fields, one a single file upload and the other a multiple.
<pre>
<?php if ($_FILES) {
print_r($_FILES);
}
?>
</pre>
<form id="frontpost" method="post" enctype="multipart/form-data">
<input type="file" name="single">
<input type="file" multiple name="multiple[]">
<button type="submit">Submit</button>
</form>
Which prints:
[single] => Array
(
[name] => foo.txt
[type] => text/html
[tmp_name] => /path/to/tmp/php/qwqerqrq
[error] => 0
[size] => 1621
)
[multiple] => Array
(
[name] => Array
(
[0] => bar.txt
[1] => baz.txt
)
[type] => Array
(
[0] => text/plain
[1] => text/plain
)
[tmp_name] => Array
(
[0] => /path/to/tmp/php/vwvwrvwrv
[1] => /path/to/tmp/php/wqerverhw
)
[error] => Array
(
[0] => 0
[1] => 0
)
[size] => Array
(
[0] => 36976
[1] => 58355
)
)
If your code is setup expecting the structure of a single file in $_FILES
, you’ll need to update it to work with the very different structure of a multi-file upload.