Save hasMany Images causes Object of class Laminas\Diactoros\UploadedFile could not be converted to string Error

Hi, if I am trying to upload many pictures at the same time i am getting an error that says: ‘Object of class Laminas\Diactoros\UploadedFile could not be converted to string’

StartsController.php:

    if ($this->request->is('post')) {
        $start->steps[] = $start;
        $start->setDirty('steps', true);
        
        $image2 =  $this->request->getData();
        debug($image2);
        
        $recipe = $this->Start->patchEntity($start, $this->request->getData(), ['associated' => 
       ['Steps']]);

add.php (view):

echo $this->Form->control(‘steps.0.image’,[‘type’=>‘file’]);

StepsTable.php:

        $validator
        ->allowEmptyFile('image')
        ->add( 'image', [
            'mimeType' => [
                'rule' => [ 'mimeType', [ 'image/jpg', 'image/png', 'image/jpeg' ] ],
                'message' => 'Please upload only jpg and png.',
            ],
            'fileSize' => [
                'rule' => [ 'fileSize', '<=', '1MB' ],
                'message' => 'Image file size must be less than 1MB.',
            ],
        ] );

The debug($image2) throws:

APP/Controller/StartsController.php (line 642)
[
‘title’ => ‘test’,
‘steps’ => [
(int) 0 => [
‘body’ => ‘test’,
‘image’ => object(Laminas\Diactoros\UploadedFile) id:0 {
private clientFilename => ‘test.jpg’
private clientMediaType => ‘image/jpeg’
private error => (int) 0
private file => ‘/tmp/phpsxf4LO’
private moved => false
private size => (int) 61717
private stream => null
},
],

but the $recipe = $this->Start->patchEntity($start, $this->request->getData(), [‘associated’ => [‘Steps’]]); throws the error:

Object of class Laminas\Diactoros\UploadedFile could not be converted to string📋

Any ideas? Thanks…

Does this help?

thanks i found that post before but i didnt look any closer because:

‘width’ => [Validation::COMPARE_GREATER_OR_EQUAL, 10],
‘height’ => [Validation::COMPARE_GREATER_OR_EQUAL, 10],

was deprecated … BUT now i see that what he wrotes before was right. The column in the database should not have the same name as what you provide with the form control… I did this before without problems (without hasmany) but in this case it should def. have a different name!

thanks