You’ll want to use a FileField
with the “multiple” attribute. The name of the field must also contain brackets: (“Files”).
$Images = FileField::create('Images[]', 'Images')
->setAttribute('multiple', 'multiple');
File upload arrays are also strangely formatted in PHP. I recommend using a function to re-format the post data in your processor method, similar to the methods described by users on the PHP site. Here is the version that I used:
/**
* Re-arrange the $_FILES array to be more like $_POST
* Allows for multiple file uploads to be handled more easily
*
* Example:
* $_FILES['field']['name'][$i] becomes $_FILES['field'][$i]['name']
*
* @param array $filePostArray
* @return array
*/
function reArrayFiles($filePostArray)
{
$isMulti = is_array($filePostArray['name']);
$fileCount = $isMulti ? count($filePostArray['name']) : 1;
$fileKeys = array_keys($filePostArray);
$newFileArray = [];
for ($i = 0; $i < $fileCount; $i++) {
foreach ($fileKeys as $key) {
if ($isMulti) {
$newFileArray[$i][$key] = $filePostArray[$key][$i];
} else {
$newFileArray[$i][$key] = $filePostArray[$key];
}
}
}
return $newFileArray;
}