我正在使用VichUploaderBundle为文章上传多个imga . 我有两个实体 - 第一个是Article,第二个是ArticleImage .
问题是,当我没有选择要上传的任何文件时,一切都很好没有致命错误,但是当我选择从我的PC上传一些图像时,我收到此错误:
给出“AppBundle \ Entity \ ArticleImage”类型的预期参数,给出“Symfony \ Component \ HttpFoundation \ File \ UploadedFile”
当我将这段代码'public function addImage(ArticleImage $ image)'更改为'//使用Symfony \ Component \ HttpFoundation \ File \ File;'时'public function addImage(File $ image)'
我收到了这种致命的错误:
关联字段“AppBundle \ Entity \ Article#$ images”类型“Doctrine \ Common \ Collections \ Collection | array”的预期值,得到“Symfony \ Component \ HttpFoundation \ File \ UploadedFile”
请帮我解决如何处理上传文件的问题
在这里你去文件:
1. Article Entity : https://pastebin.com/ppzrbBis
2. ArticleImage Entity : https://pastebin.com/HGpPAxHT
3. Form Article Type : https://pastebin.com/SWc6KmKZ
4. Arctile Controller Edit Action : https://pastebin.com/P6hfbqKC
5. Config YML: https://pastebin.com/1Ax6D1Vx