F
Filament3d ago
Dhru

Fileupload: How to show a default image that the user can override with their own image

Basically I want to show a default image in the file upload form that the users can choose to replace by uploading their own image. Couldn't find an easy way to do this in the docs (but I think I am probably missing something) Thanks.
1 Reply
Dhru
DhruOP3d ago
actually did a search on discord and found a solution haven't tired it yet: Forms\Components\FileUpload::make('company_logo') ->label('Company Logo') ->image() ->required() ->rules([ 'image', 'mimes:jpeg,png,jpg', 'max:2048', 'dimensions:max_width=300,max_height=200', ]) ->formatStateUsing(fn ($record) => $record?->company_logo ?? asset('/images/company_logo.png')) ->disk('company_logo') // from filesystems.php ->maxFiles(1)
Want results from more Discord servers?
Add your server