Bird
0
0

Which of the following is the correct way to access the name of an uploaded file with input name userfile?

easy📝 Syntax Q12 of 15
PHP - Superglobals and Web Context
Which of the following is the correct way to access the name of an uploaded file with input name userfile?
A$_FILES['userfile']['filename']
B$_FILES['userfile']['file']
C$_FILES['userfile']['file_name']
D$_FILES['userfile']['name']
Step-by-Step Solution
Solution:
  1. Step 1: Recall the structure of $_FILES

    Each uploaded file's info is stored in an array with keys like 'name', 'type', 'tmp_name', 'error', and 'size'.
  2. Step 2: Identify the correct key for the original filename

    The key for the original filename is 'name', not 'filename' or 'file_name'.
  3. Final Answer:

    $_FILES['userfile']['name'] -> Option D
  4. Quick Check:

    Filename key = 'name' [OK]
Quick Trick: Use 'name' key to get original filename from $_FILES [OK]
Common Mistakes:
  • Using 'filename' or 'file_name' instead of 'name'
  • Confusing keys with other $_FILES elements
  • Trying to access $_POST for file names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes