Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to store a file on the local disk using Laravel's Storage facade.
Laravel
Storage::disk('[1]')->put('example.txt', 'Hello World');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'public' instead of 'local' for local disk storage.
Using cloud disks like 's3' when local storage is intended.
✗ Incorrect
Laravel's local disk storage is accessed using the 'local' disk name.
2fill in blank
mediumComplete the code to check if a file exists on the local disk.
Laravel
if (Storage::disk('local')->[1]('example.txt')) { // File exists }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'has' which is not a method for checking files.
Using 'contains' which is for string operations.
✗ Incorrect
The method to check if a file exists is exists.
3fill in blank
hardFix the error in the code to retrieve the contents of a file from local disk storage.
Laravel
$contents = Storage::disk('local')->[1]('example.txt');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'getContents' which is not a Laravel Storage method.
Using 'read' which does not exist in this context.
✗ Incorrect
The correct method to get file contents is get.
4fill in blank
hardFill both blanks to delete a file from the local disk storage.
Laravel
Storage::[1]('[2]');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'remove' which is not a Laravel Storage method.
Using disk name instead of filename as second argument.
✗ Incorrect
Use delete method with the filename to remove a file.
5fill in blank
hardFill all three blanks to copy a file from one location to another on the local disk.
Laravel
Storage::disk('[1]')->[2]('old.txt', '[3]');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'public' disk instead of 'local' for local storage.
Using 'move' instead of 'copy' which deletes the original.
✗ Incorrect
Use the copy method on the 'local' disk to copy 'old.txt' to 'new.txt'.