FIle Upload Image preview on edit action load
When I choose to edit a record, if it has an image already, this doesnt appear on the edit screen. If I was to upload a new image, I'd have that preview, but not when an image already exists against the record?
17 Replies
Uploading it just puts into the browser, so it will be how it's re-rendered. Please confirm the storage disk config, the field config and if the file is publically accessible too.
I believe so, I can view it in the table view as an image column:
Its just on the edit page, a user should be able to see the record that already exists
And the URL that I store in the DB... I can go to the browser with it and the image loads correctly
Are you storing the URL as a full URL or a URL Path?
the 'avatar' field itself is a full url.
but as a hidden field I also store the path
Like that
That's why, never store as a full URL This is the reason we have disks etc in Laravel.
Try removing the URL and storage off. so:
/offers/01 etc
The main reason for the full URL as it's what our FE request on the API side, and easier to just store it. Maybve swapping them around would work, Ill give that a go
No you shouldn't do that, only the S3 driver does that. If you want the full URL on the API put a getter/setter into the model for avatar_url which returns it with storage url.
When you go live now, you have to upload the urls.
So that would look the same in the API but we dont store it as a full URL?
Just trying to learn π
Yep
Cool. Thank you π
ChatGPT Should show you how to quickly do it, then ask it to explain it so you get a better understanding, it's just a basic Laravel Model option
Is this for the getter/setter?
Yeah
Perfect, cheers
All sorted and running now. Cheers for the help π