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),


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