Recall & Review
beginner
What is the basic Laravel method to handle a file upload from a form?
Use the
store() or storeAs() method on the uploaded file instance from the request, e.g., $request->file('photo')->store('photos');.Click to reveal answer
beginner
How do you validate a file upload in Laravel?
Use the
validate() method on the request with rules like 'file' => 'required|file|mimes:jpg,png|max:2048' to check presence, type, and size.Click to reveal answer
beginner
What does the
store() method return after saving a file?It returns the path where the file was stored relative to the disk root, e.g.,
photos/filename.jpg.Click to reveal answer
intermediate
How can you customize the filename when storing an uploaded file in Laravel?
Use the
storeAs() method and pass the desired filename as the second argument, e.g., $request->file('photo')->storeAs('photos', 'customname.jpg');.Click to reveal answer
intermediate
Why should you use Laravel's storage facade instead of moving files manually?
Because Laravel's storage facade handles different filesystems, security, and paths consistently, making your code cleaner and more portable.
Click to reveal answer
Which Laravel method is used to get the uploaded file from a request?
✗ Incorrect
Use
$request->file('input_name') to access the uploaded file object.What validation rule ensures a file is an image in Laravel?
✗ Incorrect
The
image rule checks if the file is an image type.What does the
store() method return after saving a file?✗ Incorrect
store() returns the relative path where the file is saved.How do you specify a custom filename when saving an uploaded file?
✗ Incorrect
Use
storeAs() to specify directory and filename.Why is it better to use Laravel's storage facade for file uploads?
✗ Incorrect
Laravel's storage facade manages filesystems and security consistently.
Explain the steps to handle a file upload in Laravel from form submission to storage.
Think about request, validation, and storage methods.
You got /4 concepts.
Describe how Laravel helps ensure uploaded files are safe and valid.
Focus on validation and storage features.
You got /4 concepts.