kikter's avatar

Array to string conversion

I tried uploading an image for my thread and I got this This error what could be wrong

use withFileUploads:
public $images = [];

$thread = Thread::create([

                'user_id' => auth()->user()->id,

                'title' => $this->title,

                'space_id' => $this->space,

                'body' => $this->body,

                'filename' => $this->images,

            ]);





        foreach ($this->images as $key => $image) {

            $path = $image->storeAs('gallery', str::random(30));

           $images = Image::make($image)->fit(1280, 720);

           Storage::put($path, (string)$images->encode());



            ThreadImages::create([

                'thread_id' => $thread->id,

                'filename' => $path,

            ]);

        }
0 likes
2 replies
kevinbui's avatar

$this->images is like an array of files, which cannot be assigned to the filename attribute.

1 like
Snapey's avatar
Snapey
Best Answer
Level 122

remove

                'filename' => $this->images,
1 like

Please or to participate in this conversation.