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.OP2y ago
anyone?
Alvaro Leon
Alvaro Leon2y ago
Have you tried to use
afterStateUpdated()
afterStateUpdated()
method?
Quin.
Quin.OP2y ago
yes don't work
Alvaro Leon
Alvaro Leon2y ago
Exactly how does not work?
Quin.
Quin.OP2y 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);
})

Did you find this page helpful?