Complete the code to delete a file using Laravel's Storage facade.
use Illuminate\Support\Facades\Storage; Storage::[1]('path/to/file.txt');
Laravel's Storage facade uses the delete method to remove files.
Complete the code to check if a file exists before deleting it.
if (Storage::[1]('path/to/file.txt')) { Storage::delete('path/to/file.txt'); }
has which is not a method in Storage facade.contains which is for collections, not files.The exists method checks if a file is present in storage.
Fix the error in the code to delete a file from a specific disk.
Storage::disk('[1]')->delete('file.txt');
The public disk is commonly used for publicly accessible files in Laravel.
Fill both blanks to delete multiple files using Laravel's Storage facade.
Storage::[1](['file1.txt', '[2]']);
The delete method can accept an array of file paths to delete multiple files at once.
Fill all three blanks to delete a file and check the result in Laravel.
$deleted = Storage::[1]('path/to/file.txt'); if ($deleted) { echo '[2]'; } else { echo '[3]'; }
The delete method returns true if the file was deleted successfully. We print a success or failure message accordingly.
