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. 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.png
Was this page helpful?