0
0
Laravelframework~10 mins

Retrieving files in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to get the contents of a file stored in Laravel's storage.

Laravel
use Illuminate\Support\Facades\Storage;

$content = Storage::[1]('example.txt');
Drag options to blanks, or click blank then click option'
Aget
Bput
Cdelete
Dexists
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'put' instead of 'get' which writes data.
Using 'delete' which removes the file.
Using 'exists' which only checks if file is present.
2fill in blank
medium

Complete the code to check if a file exists in Laravel's storage.

Laravel
use Illuminate\Support\Facades\Storage;

if (Storage::[1]('photo.jpg')) {
    // File exists
}
Drag options to blanks, or click blank then click option'
Aexists
Bdelete
Ccopy
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' which reads file content.
Using 'delete' which removes the file.
Using 'copy' which duplicates files.
3fill in blank
hard

Fix the error in the code to retrieve a file's URL from Laravel storage.

Laravel
use Illuminate\Support\Facades\Storage;

$url = Storage::[1]('documents/report.pdf');
Drag options to blanks, or click blank then click option'
Aget
Burl
Cexists
Dput
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' which returns file content instead of URL.
Using 'exists' which returns a boolean.
Using 'put' which writes data.
4fill in blank
hard

Fill both blanks to retrieve a file's size and check if it exists in Laravel storage.

Laravel
use Illuminate\Support\Facades\Storage;

if (Storage::[1]('image.png')) {
    $size = Storage::[2]('image.png');
}
Drag options to blanks, or click blank then click option'
Aexists
Bsize
Cget
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' to check existence or get size.
Using 'delete' which removes the file.
5fill in blank
hard

Fill all three blanks to retrieve the file's last modified time, check if it exists, and get its URL in Laravel storage.

Laravel
use Illuminate\Support\Facades\Storage;

if (Storage::[1]('video.mp4')) {
    $time = Storage::[2]('video.mp4');
    $link = Storage::[3]('video.mp4');
}
Drag options to blanks, or click blank then click option'
Aexists
BlastModified
Curl
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' instead of 'url' for the link.
Not checking if file exists before accessing properties.