- Bundle version : vich/uploader-bundle 1.17.0 (checked with composer show -i)
- Symfony version : 5.2.5
- PHP version : 8.0.2
I had a perfectly working multi files upload. Upload one file at a time with one "browse" button. It's basically a Package entity that can have Many images.
I am trying to modify it to upload all files at once through only one "browse" window. Select multiple files with Ctrl / shift.
I tried tons of modifications by gathering informations on stackoverflow / youtube / github ... I revert back most of them and here is the current situation.
I have the browse button, I can select multiple files at once and when I click SAVE I have this error message :
Expected argument of type "App\Entity\Image", "App\Entity\Package" given at property path "images".
It comes from public function addImage(Image $image): self
in Package.php
If I add a dump($image);
in this function and select two images in my Browse popup, hit save, I can see that both images are added.
Now if I remove the Entity check :
public function addImage($image): self
There is a third dump($image); called with a Package entity provided.
Here is my code.
https://gist.github.com/cedricgeffroy/b977ecbea8c7e603eac97d623a936cf0
I will post below the code for future googlers if I find the solution, but It seems that a gist was the best option for now considering the number of files.
So am I missing something or is my setup missing some logic? Thank you anyway for reading and any advice will be appreciated.