Bird
0
0

Which of these is the correct way to access a file named 'avatar' from a multipart form in a Remix action?

easy📝 Conceptual Q2 of 15
Remix - Advanced Patterns
Which of these is the correct way to access a file named 'avatar' from a multipart form in a Remix action?
Aconst file = formData.get('avatar')
Bconst file = request.files.avatar
Cconst file = request.body.avatar
Dconst file = formData.avatar
Step-by-Step Solution
Solution:
  1. Step 1: Understand formData API

    When parsing multipart form data, Remix returns a FormData object where files are accessed using get with the field name.
  2. Step 2: Access file by field name

    Using formData.get('avatar') correctly retrieves the file object uploaded under that field.
  3. Final Answer:

    const file = formData.get('avatar') -> Option A
  4. Quick Check:

    Access file from FormData with get() = A [OK]
Quick Trick: Use formData.get('fieldName') to get uploaded files [OK]
Common Mistakes:
MISTAKES
  • Trying to access files directly on request object
  • Using dot notation instead of get() method
  • Assuming files are in request.body

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes