我尝试在Symfony2中上传多个文件。我需要在没有控制器处理的情况下这样做,并且我尝试做那个trought生命周期,但我不能创建我的实体的多个实例,我想我需要修改,方法:
/**
* Sets file.
*
* @param UploadedFile $photo
*/
public function setPhoto(UploadedFile $photo = null)
{
$this->photo = $photo;
if (isset($this->path)) {
$this->temp = $this->path;
$this->path = null;
} else {
$this->path = 'initial';
}
}
这样的事情:
/**
* Sets file.
*
* @param ArrayCollection $photo
*/
public function setPhoto(ArrayCollection $photo = null)
{
foreach ($photo as $photos) {
$file = new UploadedFile();
$this->photo = $file;
}
}
我是新手帮助。