Bird
0
0

You want to allow users to upload multiple images using an input named 'photos[]'. How is the $_FILES array structured for this input?

hard📝 Application Q8 of 15
PHP - Superglobals and Web Context
You want to allow users to upload multiple images using an input named 'photos[]'. How is the $_FILES array structured for this input?
A<code>$_FILES['photos']['name'][0]</code>, <code>$_FILES['photos']['name'][1]</code>, etc.
B<code>$_FILES['photos'][0]['name']</code>, <code>$_FILES['photos'][1]['name']</code>, etc.
C<code>$_FILES['photos']['name']</code> as a string with comma-separated filenames
D<code>$_FILES['photos']['name']</code> as a single filename string
Step-by-Step Solution
Solution:
  1. Step 1: Understand multiple file uploads with array inputs

    When input name ends with '[]', PHP creates arrays for each file property inside $_FILES.
  2. Step 2: Structure of $_FILES for multiple files

    Each key like 'name', 'tmp_name', 'error' is an array indexed by file number, e.g., $_FILES['photos']['name'][0].
  3. Final Answer:

    $_FILES['photos']['name'][0], $_FILES['photos']['name'][1], etc. -> Option A
  4. Quick Check:

    Multiple files use indexed arrays inside each key [OK]
Quick Trick: Multiple uploads use indexed arrays inside $_FILES keys [OK]
Common Mistakes:
  • Assuming $_FILES['photos'] is an array of arrays
  • Expecting comma-separated string of filenames
  • Using $_FILES['photos'][0]['name'] which is incorrect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes