Reactive file upload firing garbled info for file names
I have a standard file upload field that has reactive() on it.
I can access other form fields reactively, but when I try and access the "attachments" field on a reactive file upload (to get the name of the file that has just been uploaded), I get this:
etc.
If I save and refresh the page, it correctly gives me:
What is going on here? It's like the reactive() is firing before the field has a chance to update itself properly?
Does anyone know of a better way to achieve this? I just need to grab the file name for displaying in another field.
7 Replies
Code for secondary field:
Looks like the temporary filename. Probably files are stored on save and not before.
Yes, that makes sense. Can you think how else I might grab the file name at the point of upload?
Maybe I need to look at tapping into Filepond's javascript callbacks instead?
No idea whether that's even possible. Sorry.
No problem! Thanks anyway. It's good to understand what's happening at least.
Is there a reactive() equivalent for "onSave()?" Like, refresh the form elements at the point of saving?
Maybe
saveFilesUsing()
or similar?OK.. not sure what that is. I can't see any reference to it in the documentation or source code.
OK, I've kind of got this working. On my FileUpload component:
On form field component:
So, obviously I'm working around the fact that the file isn't immediately saved on upload by writing the tmp uploaded file name to an additional field in the DB. I can then call it back from the reactive() refresh.