F
Filament12mo ago
SJ

Upload Files automatically in FileUpload after Drag & Drop

I would like to create a simple file upload form that automatically saves the files after drag & drop or after file selection in the location specified in the code without an additional submit button. Would this be possible with Filament Forms?
public function form(Form $form): Form
{
return $form
->statePath('data')
->schema([
FileUpload::make('file')
->label('Dateien hochladen')
->disk('s3')
->directory($this->path)
->imagePreviewHeight('150')
->preserveFilenames()
->multiple()
->moveFiles()
->removeUploadedFileButtonPosition('right')
->uploadButtonPosition('right')
->uploadProgressIndicatorPosition('left')
]);
}
public function form(Form $form): Form
{
return $form
->statePath('data')
->schema([
FileUpload::make('file')
->label('Dateien hochladen')
->disk('s3')
->directory($this->path)
->imagePreviewHeight('150')
->preserveFilenames()
->multiple()
->moveFiles()
->removeUploadedFileButtonPosition('right')
->uploadButtonPosition('right')
->uploadProgressIndicatorPosition('left')
]);
}
Solution:
Okay after some digging in the Classes i found this: ```php ->afterStateUpdated(function (FileUpload $component) { $component->saveUploadedFiles($component); $this->updateMedia();...
Jump to solution
1 Reply
Solution
SJ
SJ12mo ago
Okay after some digging in the Classes i found this:
->afterStateUpdated(function (FileUpload $component) {
$component->saveUploadedFiles($component);
$this->updateMedia();
})
->afterStateUpdated(function (FileUpload $component) {
$component->saveUploadedFiles($component);
$this->updateMedia();
})
Want results from more Discord servers?
Add your server