Following the Laravel docs (I'm using using Laravel in docker using sail) I created a symlink for the storages php artisan storage:link
. I tried to re-create the links by using the full path starting from root as well.
Then I store a file with
// ...
$filename = 'signatures/signature_' . auth()->user()->id . '-' . uniqid() . '.' . $image_type;
Storage::disk('public')->put($filename, $image_base64);
After that I am successfully able to open my file from the console:
open public/storage/signatures/signature_101-62a876ce68884.png
When I try to access if from my url, I get a 404:
http://laravel.test/storage/signatures/signature_101-62a876ce68884.png
I noticed that by trying to display the image:
<img src="{{ url('/storage/' . $clients->signature->filename) }}">
Finally I tried
rm public/storage
php artisan optimize:clear
php artisan storage:link
without success
I found the solution. Laravel advising to use sail in the first place and the documentation does not cover this behaviour.
The symlink must be created in the container!
In the root of the project:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.