Skip to content
Home Tutorials Roadmaps Courses
Log in Join free
Tutorials Laravel Storage Facade
Laravel Advanced FREE

Storage Facade

Lesson 2 of 17 Advanced Interactive

Storage facade provides filesystem abstraction.

Disks

  • local � storage/app
  • public � storage/app/public
  • s3 � Amazon S3

Syntax

LARAVEL
Storage::put("file.txt", "content");
$content = Storage::get("file.txt");
$exists = Storage::exists("file.txt");
$url = Storage::url("file.txt");
Storage::delete("file.txt");
$files = Storage::files("directory");
Laravel Storage
PHP
<?php
use Illuminate\Support\Facades\Storage;

// Local disk
Storage::put("file.txt", "Hello!");

// Public disk (symlink: php artisan storage:link)
Storage::disk("public")->put("avatars/1.png", $contents);

// Read
$content = Storage::get("file.txt");

// Exists / delete
$exists = Storage::exists("file.txt");
Storage::delete("file.txt");

// URLs
$url = Storage::disk("public")->url("avatars/1.png");
$size = Storage::size("file.txt");

// Cloud (S3 example)
Storage::disk("s3")->put("uploads/notes.txt", "Data");

// Directory scanning
$files = Storage::files("avatars");
$all = Storage::allFiles();

Practice

1
Exercise

Write to a file and read it back.

Answer
Storage::put("data.txt", "Hello");
$content = Storage::get("data.txt");

Quick Quiz

1

Which disk is publicly accessible?

The public disk serves files via public URLs.

Interview Questions

Abstracts the filesystem, allowing switching between local, S3, or other drivers without changing code.