How to display a file uploaded in a previous step in a Filament wizard form (before submission)?

I’m using a multi-step (wizard) form in Laravel + Filament. In the first step, the user uploads a file using the FileUpload component. Is it possible to access or display that uploaded file in a later step (e.g., a Review step), even before the form is submitted? I’d like to show a preview or a link to the file that was attached in the earlier step.
7 Replies
Lara Zeus
Lara Zeus5d ago
did you try $get('file')
Renan
RenanOP5d ago
would it be something like that? @Lara Zeus
No description
Lara Zeus
Lara Zeus5d ago
can you share some code so we can understand more what are you trying to do. in the final step of the wizard how you want to display the uploaded file?
Renan
RenanOP5d ago
this is my first step @Lara Zeus
No description
Renan
RenanOP5d ago
and I would like to display a preview or something like that in my last step, which is a data review step
No description
Renan
RenanOP5d ago
but what comes from $document[0] is something like an id maybe what I'm writing might seem a little confusing, I'm using the help of a translator hehehe I got what I wanted. Instead of accessing $document[0], I retrieved the first value of the array regardless of its key. Since only one document is uploaded, that’s enough.
if (is_array($document)) {
$document = collect($document)->first();
}
if (is_array($document)) {
$document = collect($document)->first();
}
If you have any suggestions, I'd be happy to hear them. :))
awcodes
awcodes5d ago
This a correct approach. FileUpload uses UUIDs for the array keys. So, collect is fine or you could use the Arr class with Arr::first(). it’s effectively the same thing.

Did you find this page helpful?