Use HeaderAction to upload file in FileUpload.

Assume I have a fileupload component in a form on my page. By pressing a header action, is it possible to upload that file (to the specified disk)? Generally when you upload something, before you press create, that file is sitting in the livewire-tmp directory, and its only when you press "Create" that the file goes to its proper directory. In this case, we dont have a create action or a model.
2 Replies
Matthew
MatthewOP2d ago
anyone?
ChesterS
ChesterS2d ago
Not sure what you're trying to do, but you can use the saveUploadedFileUsing method.
Actions\Action::make('test')
->form([
FileUpload::make('files')
->saveUploadedFileUsing(fn ($file) => dd($file))
])
Actions\Action::make('test')
->form([
FileUpload::make('files')
->saveUploadedFileUsing(fn ($file) => dd($file))
])
If you want to handle the file creation manually, you can set storeFiles(false) in the fileupload, and then get the raw state and do w/e you want
Actions\Action::make('test')
->form([
FileUpload::make('files')
->storeFiles(false)
])
->action(function(Form $form) {
dd($form->getRawState());
}),
Actions\Action::make('test')
->form([
FileUpload::make('files')
->storeFiles(false)
])
->action(function(Form $form) {
dd($form->getRawState());
}),
hope it helps
Want results from more Discord servers?
Add your server