Bird
0
0

What will the following PHP code output if a file named 'document.pdf' is uploaded successfully?

medium📝 Predict Output Q4 of 15
PHP - Superglobals and Web Context
What will the following PHP code output if a file named 'document.pdf' is uploaded successfully?
echo $_FILES['upload']['name'];
Atmp_name
Bupload
Cerror
Ddocument.pdf
Step-by-Step Solution
Solution:
  1. Step 1: Understand the 'name' key in $_FILES

    The 'name' key holds the original filename of the uploaded file as sent by the client.
  2. Step 2: Analyze the echo statement

    Echoing $_FILES['upload']['name'] prints the original filename, which is 'document.pdf'.
  3. Final Answer:

    document.pdf -> Option D
  4. Quick Check:

    $_FILES['upload']['name'] = original filename [OK]
Quick Trick: Use 'name' key to get original uploaded filename [OK]
Common Mistakes:
  • Printing the input field name instead of file name
  • Confusing 'tmp_name' with 'name'
  • Expecting error code instead of filename

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes