I've been trying to upload multiple files in a form but I just cannot find a solution that would work for me. Whenever I add multiple files to my input, only one of those files gets passed to the controller and uploaded.
Controller.php
// File uploading
$files = $auto->getImages();
$images = array();
if($files != null) {
$key = 0;
foreach ($files as $file)
{
$fileName = md5(uniqid()) . '.' . $file->guessExtension();
$file->move(
$this->getParameter('car_adds'),
$fileName
);
$images[$key++] = $fileName;
}
$auto->setImages($images);
}
$auto->getImages() gives me a string value instead of an array value, therefor, whenever I try to foreach loop it I get an empty result and no file upload.
I tried renaming my image form widget to "form[images][]" instead of "form[images]" which is generated by the formbuilder however when I do that I get the following error: 
FormType.php
->add('images', FileType::class, array(
'label' => false,
'data_class' => null,
'label_attr' => array('class' => $label_offset),
'required' => false,
'attr' => array(
'class' => $styles,
'multiple' => true)))
Entity.php
/**
* @var array
*
* @Assert\Image(
* mimeTypes = {
* "image/png",
* "image/pjpeg",
* "image/jpeg",
* "image/gif"
* },
* mimeTypesMessage="Failas yra netinkamo formato",
* maxSize = "10M",
* maxSizeMessage="Failas yra per didelis"
* )
* @ORM\Column(name="images", type="array", nullable=true)
*/
private $images;
/**
* Set images
*
* @param array $images
*
* @return Auto
*/
public function setImages($images)
{
$this->images = $images;
return $this;
}
/**
* Get images
*
* @return array
*/
public function getImages()
{
return $this->images;
}
This is my first project that I'm trying to build with Symfony 3 so I'm assuming there must be something that I may have overlooked.