php - How to get a file stored in storage/app/?


I've been trying to store a file to (and get it from)storage/app/, following the doc.

After I runphp artisan storage:link, I can see that there is a link to the puiblic folder.

If I put a file with the following code...

    Storage::put('/images/blah.png', $file);

...the storage will look like this.

I'm not really sure if the link is working properly, since thisblah.png can't be retrieved.

So far, I've changed the access level ofstorage bychmod -R 755 storage/, and put the complete URL (http://localhost:8000/storage/images/blah.png. This is whatasset('storage/images/blah.png') returns). Still, I'm getting 404 error (Not Found).

Inconfig/filessystems.php. the default is set to belocal. (i.e.'default' => 'local')

Do you see anything I'm doing wrong?

Any advice will be appreciated.


This is how the configuration of the public disk looks like...

'public' => [
        'driver'     => 'local',
        'root'       => storage_path('app/public'),
        'url'        => env('APP_URL') . '/storage',
        'visibility' => 'public',
 //env('APP_URL').'/storage' returns 'root/storage/app/public'



The public disk is intended for files that are going to be publicly accessible. By default, the public disk uses the local driver and stores these files in storage/app/public. To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public.

To create a symbolic link from public/storage to storage/app/public, go to the root folder:

ln -s storage/app/public public/storage

Then, you can save the file to storage/app/public:

Storage::put('/public/images/blah.png', $file);
// the blah.png is located at storage/app/public/images/blah.png
// you can also get the file path by
// $image_path = storage_path() . "/app/public/images/blah.png";

Then, you can access the image file as:




in the controller


and in the file config/filesystems.php

'default' => env('FILESYSTEM_DRIVER', 'local'),

and the disk

'disks' => [

    'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),

    'images' => [ // used for Backpack/CRUD (in elFinder)
        'driver' => 'local',
        'root'   => storage_path('app/pdfs'),

    'public' => [
        'driver' => 'local',
        'root' => storage_path('app/public'),
        'url' => env('APP_URL').'/storage',
        'visibility' => 'public',

    's3' => [
        'driver' => 's3',
        'key' => env('AWS_KEY'),
        'secret' => env('AWS_SECRET'),
        'region' => env('AWS_REGION'),
        'bucket' => env('AWS_BUCKET'),


People are also looking for solutions to the problem: php - How to share same connection with multiple instances of the object?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.