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.
PS
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'
Answer
Solution:
To create a symbolic link from public/storage to storage/app/public, go to the root folder:
Then, you can save the file to storage/app/public:
Then, you can access the image file as:
Answer
Solution:
in the controller
and in the file config/filesystems.php
and the disk