© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•16mo ago•
3 replies
quantumleaps

upload image from afterStateUpdate of another component

i have a form where I have an image upload input with a few other fields. One of the fields is for barcode, the ideal action I want is the server to check external api if an image for it exists, and if it does, fill the image in automatically in the image upload input.

This is my current code, but it seems like the front end preview component is stuck on
waiting for size
waiting for size
. I don't know if I'm doing it the wrong way, since I've tried a few other ways but this is the one with which I was able to get the farthest. Image Size Is under the file upload limit, so I don't think that's the actual issue.

                        $image_url = $openfoodfacts_result->getData()['image_url'];
                        try {
                            $image_contents = file_get_contents($image_url);
                            $image_name = basename($image_url);
                            $local_path = "images/products/$image_name";
                            Storage::disk('public')->put($local_path, $image_contents);
                            $set('product_image_url', [$local_path]);
                            $livewire->dispatch('refreshFileUpload', 'product_image_url');
                        } catch (\Exception $e) {
                            dd($e);
                        }
                        $image_url = $openfoodfacts_result->getData()['image_url'];
                        try {
                            $image_contents = file_get_contents($image_url);
                            $image_name = basename($image_url);
                            $local_path = "images/products/$image_name";
                            Storage::disk('public')->put($local_path, $image_contents);
                            $set('product_image_url', [$local_path]);
                            $livewire->dispatch('refreshFileUpload', 'product_image_url');
                        } catch (\Exception $e) {
                            dd($e);
                        }
image.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

call component from another component
FilamentFFilament / ❓┊help
2y ago
afterstateupdate
FilamentFFilament / ❓┊help
2y ago
Upload image from table
FilamentFFilament / ❓┊help
10mo ago
Upload image from URL
FilamentFFilament / ❓┊help
2y ago