Replies: 2 comments
-
Not sure if it's the most clean way to do it, but I created an $images = [] property on the Livewire component. Each upload action on the Livewire component adds an image to this array. For actually storing the images, I created a save method. So the user uploads the images first, then clicks save to store the images. The save method has 2 steps. First you store each image via the $this->storeAs('/', 'filename', 'diskName') method which is part of the WithFileUploads trait that Livewire uses to store files. Next, you use the $model->addMediaFromDisk('filename', 'diskName')->toMediaCollection('yourMediaCollection', 'diskName') to add the images to the desired mediacollection and move them to the disk/storagelocation of your choice. In simplified code it looks like this:
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
how can we upload image with the this library and Laravel Livewire?
we don't use Media library pro and how can do that without it? it means using not pro version
Beta Was this translation helpful? Give feedback.
All reactions