Upload Image/File from URL
Hello.
I have an action on Edit Resource where i randomly download an image from web and upload it to the field but its not working.. what i am doing wrong.
Here is what i am trying..
7 Replies
How can i replace the image state?
you need to download the image, save it to the filesystem disk, then save the relative file name in the disk to the database
that will allow filament to generate a URL from it
you can check the format and location of files by uploading one manually and seeing what the file upload field saves to the db normally
Let me try that!
Flare
foreach() argument must be of type array|object, string given - The error occurred at http://mortgagecs.test/admin/pages/20/edit
The file gets uploaded, saved properly to database and when i reload the file also gets previewed.
I am not sure why i get this error.
Oh I have this line which triggers this error:
How would reload the field/component from action so that it previews newly uploaded file?
I have a workaround for now to reload the entire page. But would be nice if i can find a way to refresh the image preview in form.
instead of
$this->refreshFormData();
try $this->data['featured_image'] = [$this->record->featured_image];
Let me try sir!
Thanks for the help!
Oh this works like a charm.
Love you Dan!