Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get the path to the Laravel Storage folder?

Tags:

php

laravel

I want to store uploaded images to my Laravel-based web app in a subdirectory of the Laravel storage directory. It's the directory at the same hierarchy level as the 'application' and 'public' directories.

Is there a framework method for doing this? I've searched the docs but can't find one.

like image 518
Garry Pettet Avatar asked May 16 '13 20:05

Garry Pettet


People also ask

Where is Laravel storage path?

Laravel's filesystem configuration file is located at config/filesystems.php . Within this file, you may configure all of your filesystem "disks". Each disk represents a particular storage driver and storage location.

What is path in Laravel?

Laravel provide several helper to get path of public directory, app directory, storage directory and base directory. It will help to store files, read file from path and also for other from controller, view files, model etc. You can see as bellow how to get path of that directory using helper one by one.

How do I save to storage folder in Laravel?

Now, if you need to change the directory and store into the storage folder directly, you need to change something in the filesystems. php file. 'local' => [ 'driver' => 'local', 'root' => storage_path('app'), ], Here, this line of code 'root' => storage_path('app'), responsible to define where to store.

How do I link my storage folder in Laravel 8?

You can link the storage folder in laravel using php artisan command and you can also run a PHP script to create a symbolic link between two folders.


2 Answers

In Laravel 3, call path('storage').

In Laravel 4, use the storage_path() helper function.

like image 39
Abishek Avatar answered Sep 28 '22 05:09

Abishek


For Laravel 5.x, use $storage_path = storage_path().

From the Laravel 5.0 docs:

storage_path

Get the fully qualified path to the storage directory.

Note also that, for Laravel 5.1 and above, per the Laravel 5.1 docs:

You may also use the storage_path function to generate a fully qualified path to a given file relative to the storage directory:

$path = storage_path('app/file.txt'); 
like image 159
Mark Amery Avatar answered Sep 28 '22 07:09

Mark Amery