How do I get the file in a upload action
on a resource page I have an action:
shows a modal, one can upload a file and it call my 'import' method.
But... what parameters do I get in my method?
I would lige to get the current record and then the fileupload so that I can 'import' the data in this case
Does not work
6 Replies
It's described in the docs. You need
$data
https://filamentphp.com/docs/2.x/tables/actions#custom-formsFilament
Actions - Table Builder - Filament
The elegant TALL stack table builder for Laravel artisans.
well... $data only contains the filename, not the FileUpload object so it's difficult to 'move' or read the file
and I do not have a callback for the action as I use in the Admin panel on a resource page
Yes that’s right. But you shouldn’t need more for an import?
If you need the FileUpload object I think you can hook into
saveFilesUsing()
I know that the file will be in the livewire tmp, but... that is 'hard-coding' 😀
eg. File:get() or file_get_contents() need the full path
Solution
Here is the solution
The trick is to store the realpath in a hidden input
@steen.rabol just wanted to say, thanks, this helped me figure out what I needed for my image uploads too