F
Filament16mo ago
Wim

FileUpload with dynamic folder name

I'm using Filament to upload product images. I would like to create a folder structure as follows:
/images/product1/image1.png, /images/product1/image2.png .... /images/productN/image1.png, /images/productN/imageN.png.
/images/product1/image1.png, /images/product1/image2.png .... /images/productN/image1.png, /images/productN/imageN.png.
Hence I would like to use the product name (product1...productN) in the ->directory() method. Anyone could provide an example on how to do this?
Solution:
Assuming you have a 'slug' field you can do ->directory(fn ($get) => $get('slug'))...
Jump to solution
2 Replies
Solution
ZedoX
ZedoX16mo ago
Assuming you have a 'slug' field you can do ->directory(fn ($get) => $get('slug'))
Wim
WimOP16mo ago
`OK thanks. That works perfectly!
Want results from more Discord servers?
Add your server