File upload not getting "stored" with record
I have a super basic file upload:
I can successfully upload an image, see it in the file system (storage folder), get no console or PHP errors etc. but when I save, then refresh the page, the file preview is gone, as if the file was never uploaded, or like I'm looking at a blank/new record.
This is probably something really obvious, but what am I missing here?
Is there some special database field (other than file_name) that I need to have configured?
(Also, my APP_URL is definitely configured correctly).
Or do I need the Spatie plugin to preserve image previews?
5 Replies
Are you casting it to array in your model as per the docs?
Thanks for responding. I thought that was referring to when multiple uploads are allowed?
Either way, it still doesn't work.
"If you're saving the file URLs using Eloquent"...
How else would I be saving them?
It's writing to the DB field, but still nothing displays when I refresh the page..
Hi @benshawuk, I'm not sure, this is just a shot in the dark... I've never used
storeFileNamesIn()
, I've always just used the column name in make()
and customized the label:
The other thing that comes to mind is php artisan storage:link
, I often forget on new projects... Did you run that?Ah yeah, that was it! Doh! I knew it would be something simple (like me being an idiot and naming the form component without any relation to the database).
Thank you!