laravel storage code example

Example 1: laravel storage hard link

php artisan storage:link

Example 2: path of app directory in controller laravel

How to get base path(Project Root) in laravel ?
base_path(); // Path of application root


How to get storage folder path in laravel ?
storage_path(); // Path of storage/


How to get app folder path in laravel ?
app_path(); // Path of app/

Example 3: laravel storage get file path

use Illuminate\Support\Facades\Storage;

$path = Storage::path('file.jpg');

Example 4: use s3 storage laravel

return Storage::disk('s3')->response('images/' . $image->filename);

Example 5: laravel store file

$path = $request->file('avatar')->store(
    'avatars', 'public'
);

Example 6: laravel filesystem

$exists = Storage::disk('s3')->exists('file.jpg');