Complete the code to get the uploaded file from the request.
$file = $request->[1]('photo');
In Laravel, to get an uploaded file from the request, use file('fieldname').
Complete the code to store the uploaded file in the 'uploads' directory.
$path = $file->[1]('uploads');
save which is not a method on the uploaded file objectmove without specifying full pathThe store method saves the uploaded file to a disk directory and returns the path.
Fix the error in the code to check if the request has a file named 'avatar'.
if ($request->[1]('avatar')) { // process file }
has which checks input but not filesexists which is not a request methodLaravel uses hasFile to check if a file was uploaded with the request.
Fill both blanks to validate that the uploaded file is required and must be an image.
$request->validate([
'photo' => '[1]|[2]'
]);file instead of image to check file typenullable which allows no fileUse required to make the file mandatory and image to ensure it is an image file.
Fill all three blanks to rename the uploaded file and move it to 'public/images'.
$file = $request->file('photo'); $filename = time() . '.' . $file->[1](); $file->[2](public_path('[3]'), $filename);
store instead of move for moving to public folderUse getClientOriginalExtension() to get the file extension, move() to move the file, and specify the folder images inside public_path().