Laravel

Laravel Storage and File Handling

January 16, 2026 1 min read 14 views

File storage in Laravel:

Store File

$path = $request->file('avatar')->store('avatars');
$path = Storage::disk('s3')->put('avatars', $file);

Store with Name

$path = $request->file('avatar')->storeAs(
    'avatars', $user->id.'.jpg'
);

Get File

$contents = Storage::get('file.txt');
$url = Storage::url('file.txt');

Delete File

Storage::delete('file.txt');
Storage::delete(['file1.txt', 'file2.txt']);

Check Existence

if (Storage::exists('file.txt')) {
    // ...
}
Share this post:

Related Posts

Comments (0)

Please log in to leave a comment. Log in

No comments yet. Be the first to comment!