F
Filament4mo ago
morty

Storing file size and mime type from uploaded file.

I understand that I should be using the afterStateUpdated method, but how can I inject these two properties from the uploaded file into the $data array? Am I supposed to use a hidden form field or is there a better way?
7 Replies
morty
mortyOP4mo ago
What I have so far:
->afterStateUpdated(function ($state) {
ray(
$state->getSize(),
$state->getMimeType(),
);
})
->afterStateUpdated(function ($state) {
ray(
$state->getSize(),
$state->getMimeType(),
);
})
I tried $set('size', $state->getSize()) but it didn't work, I'm assuming because there is no $size property on the component.
awcodes
awcodes4mo ago
I don’t think the state at this point is the TemporaryFileUpload. dd($state) to check.
morty
mortyOP4mo ago
it is
awcodes
awcodes4mo ago
I would expect ->getSize() to work then. But yea. You can $set a form field that doesn’t exist.
morty
mortyOP4mo ago
Wait you can? I tried and didn't get anything in the $data array.
awcodes
awcodes4mo ago
Not following what does $state have to do with $data. They are 2 completely different things.
morty
mortyOP4mo ago
Isn't the $data array what is saved to the database? Sorry maybe I'm confused. I was just dumping it out of ->action(fn ($data) => ray($data))
Want results from more Discord servers?
Add your server