© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
49 replies
_andypeacock

Fileupload not saving to DB

Hi,
I've got what I thought would be a simple fileupload component:

FileUpload::make('image')
  ->directory('blog-attachments')
  ->visibility('public')
  ->preserveFilenames()
  ->storeFileNamesIn('image')
  ->imageEditor()
  ->imageEditorAspectRatios([
       null,
       '16:9',
       '4:3',
       '1:1',
  ])
  ->moveFiles()
  ->columnSpan(2),
FileUpload::make('image')
  ->directory('blog-attachments')
  ->visibility('public')
  ->preserveFilenames()
  ->storeFileNamesIn('image')
  ->imageEditor()
  ->imageEditorAspectRatios([
       null,
       '16:9',
       '4:3',
       '1:1',
  ])
  ->moveFiles()
  ->columnSpan(2),


The DB column is called "image", it's a varchar(255). It's listed in the $fillable property of the model.

The image file is uploaded to storage/app/livewire-tmp/ successfully. One point, it's saved in the format "4UwLQXBBr7UQzl9KU0PPfcFCPwM0AA-metaYXNhbmEtYm9hcmQucG5n-.png", rather then the original filenames, which I thought preserveFilenames() would prevent.

The directory 'blog-attachments' is never created.

Everything is good in the UI - no errors in the browser nor console.

But when I save the resource, the image field in the DB is populated with "[]"

If I change the component config to the bare minimum (FileUpload::make('image')), then the [] is replaced with a null.

Any ideas?
Solution
I've removed stancl/tenancy. Image upload now working other than the URL being incorrect, but that's a minor issue. I started using stancl because I did want tenancy, but not the one user:many tenants model that Filament has. But you're right - there are easier ways than the formal packages 🙂
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

FileUpload Not storing to DB
FilamentFFilament / ❓┊help
3y ago
Pivot not saving to db?
FilamentFFilament / ❓┊help
3y ago
FileUpload - Manipulate image before saving.
FilamentFFilament / ❓┊help
3y ago