Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

CrastyCrap's avatar

Filament file upload error

Hey, i am trying to add file upload to my filament app and i keep getting that error

Trait "Filament\Forms\Components\Concerns\HasUploadingMessage" not found

my form

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                FileUpload::make('avatar'),
                Forms\Components\TextInput::make('name')
                    ->required()
                    ->maxLength(255),
                Forms\Components\TextInput::make('avatar')
                    ->maxLength(255),
                Forms\Components\Textarea::make('description')
                    ->required()
                    ->maxLength(65535)
                    ->columnSpanFull(),
                Forms\Components\TextInput::make('phone')
                    ->tel()
                    ->required()
                    ->maxLength(255),
                Forms\Components\TextInput::make('email')
                    ->email()
                    ->required()
                    ->maxLength(255),
                Forms\Components\TextInput::make('address')
                    ->required()
                    ->maxLength(255),
                Forms\Components\TextInput::make('lat')
                    ->required()
                    ->numeric(),
                Forms\Components\TextInput::make('lng')
                    ->required()
                    ->numeric(),
            ]);
    }
0 likes
1 reply
LaryAI's avatar
Level 58

It looks like you're encountering an error due to a missing trait in your Filament application. The error message "Trait Filament\Forms\Components\Concerns\HasUploadingMessage not found" suggests that there is a reference to a non-existent trait in your code or dependencies.

Here's how you can resolve this issue:

  1. Check for Typographical Errors: First, ensure that there is no typographical error in your code where you might have mistakenly referenced the HasUploadingMessage trait.

  2. Update Filament: Ensure that your Filament installation is up to date. Sometimes, features or fixes are added in newer versions that might resolve your issue. You can update Filament using Composer:

    composer update filament/filament
    
  3. Review Filament Documentation: Check the latest Filament documentation to see if there have been any changes to the way file uploads are handled. Ensure that you are using the correct classes and traits.

  4. Simplify Your Form Code: There seems to be a redundancy in your form code where you have both a FileUpload and a TextInput for 'avatar'. You should only use FileUpload for file inputs. Here's a simplified version of your form code:

    public static function form(Form $form): Form
    {
        return $form->schema([
            Forms\Components\FileUpload::make('avatar')
                ->disk('public')  // Ensure you specify the correct disk
                ->directory('avatars'),  // Specify the directory
            Forms\Components\TextInput::make('name')
                ->required()
                ->maxLength(255),
            Forms\Components\Textarea::make('description')
                ->required()
                ->maxLength(65535)
                ->columnSpanFull(),
            Forms\Components\TextInput::make('phone')
                ->tel()
                ->required()
                ->maxLength(255),
            Forms\Components\TextInput::make('email')
                ->email()
                ->required()
                ->maxLength(255),
            Forms\Components\TextInput::make('address')
                ->required()
                ->maxLength(255),
            Forms\Components\TextInput::make('lat')
                ->required()
                ->numeric(),
            Forms\Components\TextInput::make('lng')
                ->required()
                ->numeric(),
        ]);
    }
    
  5. Check for Missing Imports: Ensure that all necessary classes are correctly imported at the top of your PHP file. For example:

    use Filament\Forms;
    use Filament\Forms\Components\FileUpload;
    

By following these steps, you should be able to resolve the error and successfully implement file uploading in your Filament application. If the problem persists, consider seeking further assistance from the Filament community or checking for issues on the Filament GitHub repository.

Please or to participate in this conversation.