I have:
const file = formData.get('documents[]')
What type is file?
const file: FormDataEntryValue | null
I need to access to file?.name.
and i got:
Property 'name' does not exist on type 'FormDataEntryValue'.
FormDataEntryValue is defined as an union of File and string:
type FormDataEntryValue = File | string;
Thus you need to check first that the variable is indeed a File:
if (file instanceof File) {
console.log(file.name);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With