Bird
0
0

What does the following Laravel code return after uploading a file named avatar.png?

medium📝 Predict Output Q5 of 15
Laravel - Request and Response
What does the following Laravel code return after uploading a file named avatar.png?
$path = $request->file('avatar')->store('avatars');
return $path;
ABoolean true if upload succeeded
BThe original filename 'avatar.png'
CAn array of file details
DA string path like 'avatars/unique_filename.png'
Step-by-Step Solution
Solution:
  1. Step 1: Understand store() method

    The store() method saves the file and returns the relative path including a generated unique filename.
  2. Step 2: Analyze output

    The returned value is a string path like 'avatars/unique_name.png', not the original filename or boolean.
  3. Final Answer:

    A string path like 'avatars/unique_filename.png' -> Option D
  4. Quick Check:

    store() returns stored file path [OK]
Quick Trick: store() returns stored file path with unique name [OK]
Common Mistakes:
  • Expecting original filename as return value
  • Assuming store() returns boolean
  • Thinking it returns file metadata array

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes