Bird
0
0

Which of the following is the correct way to check if a form field contains a file in Remix?

easy📝 Syntax Q12 of 15
Remix - Advanced Patterns
Which of the following is the correct way to check if a form field contains a file in Remix?
Aif (formData.get('file') === 'file')
Bif (formData.get('file') instanceof File)
Cif (typeof formData.get('file') === 'string')
Dif (formData.has('file'))
Step-by-Step Solution
Solution:
  1. Step 1: Understand formData.get() returns

    The formData.get('file') returns the value of the field, which can be a File object for uploads.
  2. Step 2: Check the type of the returned value

    To confirm it's a file, check if it is an instance of File using instanceof File.
  3. Final Answer:

    if (formData.get('file') instanceof File) -> Option B
  4. Quick Check:

    Check file type with instanceof File = B [OK]
Quick Trick: Use instanceof File to detect uploaded files [OK]
Common Mistakes:
MISTAKES
  • Comparing to string 'file' instead of checking type
  • Checking typeof as string which is incorrect for File objects
  • Using formData.has() which only checks presence, not type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes