Get image size from file upload

I need to get the image size from the file upload form component and send that over an api resource. I can't seem to find anything about this in the docs, any ideas?
6 Replies
LeandroFerreira
->afterStateUpdated(function ($state) {
//$size = $state->getSize();
//...
})
->afterStateUpdated(function ($state) {
//$size = $state->getSize();
//...
})
?
awcodes
awcodes2y ago
Won’t state be a string at this point? Would probably need to do it saveUploadedFileUsing() so you’d have access to the temporary file upload. I guess you could do it in afterStateUpdated() using the Storage facade to get that data from the file.
LeandroFerreira
state is a Livewire\TemporaryUploadedFile i think
Kanalaetxebarria
KanalaetxebarriaOP2y ago
This actually works! However I actually need to call the getimagesize method as I need the width & height of the image (should've been more specific😅 ). In which case, it doesn't work
LeandroFerreira
try getimagesize($state->getRealPath())
Kanalaetxebarria
KanalaetxebarriaOP2y ago
That did the trick, thanks!
Want results from more Discord servers?
Add your server