我想用POST请求上传多个文件(不使用Ajax)。我可以像这样使用Symfony 2表单集合字段和文件类型吗:
实体中的代码:
public $pictures;
public function __construct()
{
$this->pictures = new \Doctrine\Common\Collections\ArrayCollection();
}
表单类中的代码:
$builder->add('pictures', 'collection', array(
'type' => 'file',
'required' => false,
'attr' => array(
'multiple' => 'multiple'
)
));
Twig中的代码:
{% for picture in form.pictures %}
<td>
{{ form_widget(picture) }}
</td>
{% endfor %}
我尝试过,但好像不起作用。它没有显示任何错误,但也没有显示输入文件。有什么想法吗?