F
Filament6mo ago
Quin.

FileUpload directly in to the field

protected function getHeaderActions(): array
{
return [
Action::make('terns')
->form([
FileUpload::make('terms')
->reactive()
])
->action(function($data) {
$filecontent = file_get_contents(storage_path('app/public/' . $data['terms']));
unlink(storage_path('app/public/' . $data['terms']));
})
->label('Upload Transaction file')
->icon('heroicon-o-folder-open'),
];
}
protected function getHeaderActions(): array
{
return [
Action::make('terns')
->form([
FileUpload::make('terms')
->reactive()
])
->action(function($data) {
$filecontent = file_get_contents(storage_path('app/public/' . $data['terms']));
unlink(storage_path('app/public/' . $data['terms']));
})
->label('Upload Transaction file')
->icon('heroicon-o-folder-open'),
];
}
This is my old code and this works just fine but i want the file upload like the screenshot and that it can read the content of the CSV with the terms inside and that it fills out the terms so that you dont have to add it yourself
No description
6 Replies
Quin.
Quin.6mo ago
anyone?
Alvaro Leon
Alvaro Leon6mo ago
Have you tried to use
afterStateUpdated()
afterStateUpdated()
method?
Quin.
Quin.6mo ago
yes don't work
Alvaro Leon
Alvaro Leon6mo ago
Exactly how does not work?
Quin.
Quin.6mo ago
i just want the values from the csv file nothing more nothing less, don't get any data from the afterStateUpdated ik just uploads the filename
->beforeStateDehydrated(function($data) {
$filecontent = file_get_contents(storage_path('app/public/' . $data['terms']));
dd($filecontent);
})
->beforeStateDehydrated(function($data) {
$filecontent = file_get_contents(storage_path('app/public/' . $data['terms']));
dd($filecontent);
})
Want results from more Discord servers?
Add your server
More Posts