© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
2 replies
o.stepan

How to get file in action form

Hi, i have this modal form on list page and i need to get file in submit method, but i do not know how, is it possible? under data is just string with file name that not exists.

class ListPayments extends ListRecords
{
    protected static string $resource = PaymentResource::class;

    protected function getHeaderActions(): array
    {
        return [
            Actions\Action::make('create')
                ->label('Import')
                ->action(function (array $data) {
                    $this->save($data);
                })
                ->modalHeading('Import payments')
                ->form([
                    Select::make('type')
                        ->options([
                            'raiffeisenbank' => 'Raiffeisenbank CSV Payment export',
                            'default' => 'Default system export',
                        ])
                        ->required(),
                    FileUpload::make('file')
                        ->acceptedFileTypes(['text/csv', 'text/plain'])
                        ->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file) {
                            return (string) Str::uuid() . '.' . $file->getClientOriginalExtension();
                        })
                        ->required()
                        ->helperText('Imported payments will be pared with current records and edited or create new records'),
                ])
                ->modalButton('Import')
        ];
    }

    public function save(array $data)
    {
        $file = $data['file'];

        dd($file);
    }
}
class ListPayments extends ListRecords
{
    protected static string $resource = PaymentResource::class;

    protected function getHeaderActions(): array
    {
        return [
            Actions\Action::make('create')
                ->label('Import')
                ->action(function (array $data) {
                    $this->save($data);
                })
                ->modalHeading('Import payments')
                ->form([
                    Select::make('type')
                        ->options([
                            'raiffeisenbank' => 'Raiffeisenbank CSV Payment export',
                            'default' => 'Default system export',
                        ])
                        ->required(),
                    FileUpload::make('file')
                        ->acceptedFileTypes(['text/csv', 'text/plain'])
                        ->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file) {
                            return (string) Str::uuid() . '.' . $file->getClientOriginalExtension();
                        })
                        ->required()
                        ->helperText('Imported payments will be pared with current records and edited or create new records'),
                ])
                ->modalButton('Import')
        ];
    }

    public function save(array $data)
    {
        $file = $data['file'];

        dd($file);
    }
}


Thanks for any help
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to get uploaded file in page action
FilamentFFilament / ❓┊help
3y ago
How to get Field component data/config in Form Action
FilamentFFilament / ❓┊help
2y ago
How to get $data from table form action?
FilamentFFilament / ❓┊help
2y ago
Form in Action
FilamentFFilament / ❓┊help
4mo ago