Skip to content

Commit 30b019b

Browse files
scott graysonscott grayson
authored andcommitted
fix: allow all file types in upload component
- Change acceptedFileTypes from ['*'] to [] to properly allow all file types - Fixes 'File of invalid type' error for files like .textClipping - Update both modal action and resource fileForm method
1 parent e0238d5 commit 30b019b

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

src/Resources/LibraryItemResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static function fileForm(Schema $schema): Schema
7070
\Filament\Forms\Components\FileUpload::make('file')
7171
->label('Upload File')
7272
->required()
73-
->acceptedFileTypes(['*'])
73+
->acceptedFileTypes([]) // Allow all file types
7474
->maxSize(10240) // 10MB
7575
->disk('public')
7676
->directory('library-files')

src/Resources/Pages/CreateFile.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CreateFile extends CreateRecord
1414
public function mount(): void
1515
{
1616
parent::mount();
17-
17+
1818
$this->parentId = request()->get('parent');
1919
}
2020

@@ -23,13 +23,13 @@ protected function mutateFormDataBeforeCreate(array $data): array
2323
$data['type'] = 'file';
2424
$data['parent_id'] = $this->parentId;
2525
$data['created_by'] = auth()->user()?->id;
26-
26+
2727
return $data;
2828
}
2929

3030
protected function getRedirectUrl(): string
3131
{
32-
return $this->parentId
32+
return $this->parentId
3333
? static::getResource()::getUrl('index', ['parent' => $this->parentId])
3434
: static::getResource()::getUrl('index');
3535
}

src/Resources/Pages/CreateFolder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CreateFolder extends CreateRecord
1414
public function mount(): void
1515
{
1616
parent::mount();
17-
17+
1818
$this->parentId = request()->get('parent');
1919
}
2020

@@ -23,13 +23,13 @@ protected function mutateFormDataBeforeCreate(array $data): array
2323
$data['type'] = 'folder';
2424
$data['parent_id'] = $this->parentId;
2525
$data['created_by'] = auth()->user()?->id;
26-
26+
2727
return $data;
2828
}
2929

3030
protected function getRedirectUrl(): string
3131
{
32-
return $this->parentId
32+
return $this->parentId
3333
? static::getResource()::getUrl('index', ['parent' => $this->parentId])
3434
: static::getResource()::getUrl('index');
3535
}

src/Resources/Pages/EditLibraryItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected function mutateFormDataBeforeFill(array $data): array
2323
unset($data['type']);
2424
unset($data['parent_id']);
2525
unset($data['created_by']);
26-
26+
2727
return $data;
2828
}
2929

src/Resources/Pages/ListLibraryItems.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ public function mount(): void
3131
protected function getHeaderActions(): array
3232
{
3333
$actions = [];
34-
34+
3535
// Add "Up One Level" action if we're in a subfolder
3636
if ($this->parentId && $this->parentFolder) {
3737
$actions[] = Action::make('up_one_level')
3838
->label('Up One Level')
3939
->icon('heroicon-o-arrow-up')
40-
->url(fn (): string =>
41-
$this->parentFolder->parent_id
40+
->url(fn (): string =>
41+
$this->parentFolder->parent_id
4242
? static::getResource()::getUrl('index', ['parent' => $this->parentFolder->parent_id])
4343
: static::getResource()::getUrl('index')
4444
)
4545
->color('gray');
4646
}
47-
47+
4848
// Add "Create Folder" modal action
4949
$actions[] = Action::make('create_folder')
5050
->label('Create Folder')
@@ -64,10 +64,10 @@ protected function getHeaderActions(): array
6464
'parent_id' => $this->parentId,
6565
'created_by' => auth()->user()?->id,
6666
]);
67-
67+
6868
$this->redirect(static::getResource()::getUrl('index', $this->parentId ? ['parent' => $this->parentId] : []));
6969
});
70-
70+
7171
// Add "Upload File" modal action
7272
$actions[] = Action::make('upload_file')
7373
->label('Upload File')
@@ -77,25 +77,25 @@ protected function getHeaderActions(): array
7777
FileUpload::make('file')
7878
->label('Upload File')
7979
->required()
80-
->acceptedFileTypes(['*'])
80+
->acceptedFileTypes([]) // Allow all file types
8181
->maxSize(10240) // 10MB
8282
->disk('public')
8383
->directory('library-files')
8484
->visibility('private'),
8585
])
8686
->action(function (array $data): void {
8787
$file = $data['file'];
88-
88+
8989
LibraryItem::create([
9090
'name' => $file->getClientOriginalName(),
9191
'type' => 'file',
9292
'parent_id' => $this->parentId,
9393
'created_by' => auth()->user()?->id,
9494
]);
95-
95+
9696
$this->redirect(static::getResource()::getUrl('index', $this->parentId ? ['parent' => $this->parentId] : []));
9797
});
98-
98+
9999
return $actions;
100100
}
101101

0 commit comments

Comments
 (0)