Level 51
have you looked at... https://laravel-livewire.com/docs/2.x/file-uploads#js-hooks
there is also... https://laravel-livewire.com/docs/2.x/polling
1 like
I have a Livewire component which uploads one or more pictures. I have a foreach loop
foreach ($this->uploads as $upload) {
//Upload stuff
}
I want to show the current status of upload, so I thought I had to update a property like so:
public $current = 0;
...
foreach ($this->uploads as $upload) {
//Upload stuff
$this->current++;
}
But this is not updating the model until the foreach finishes and at the end I have a final $current with the total of uploaded images.
So I thought I would emit an event to a "progress-bar" component like so:
foreach ($this->uploads as $upload) {
//Upload stuff
$this->current += 1;
$this->emit('updateProgressBar', $current);
}
But this gives the same result.... How can I emit an event or update a property after each image uploaded?
have you looked at... https://laravel-livewire.com/docs/2.x/file-uploads#js-hooks
there is also... https://laravel-livewire.com/docs/2.x/polling
Please or to participate in this conversation.