I've created a sub folder for each user in local storage disk with this command:
if(! Storage::disk('public')->has("users/".$username."_".Auth::user()->id)){
Storage::makeDirectory("public/users/".$username."_".Auth::user()->id);
and it works!
So now when i save a file, all goes in the user's folder, that is in:
storage/app/public/users/userX
storage/app/public/users/userY
etc.
Then I build a sim link with the command: php aritsan storage:link
And it works.
But when im trying to serve the files i've allways nothing to serve! If im using code like:
Storage::url("$urlToFile");
where $urlToFile
contains something like "public/users/userX/file.png"
it gives me back:
/storage/users/userX/file.png
and I cant use it even if i put function like assett()
in front!
how can i solve it?
Thanks in advance!
According to the docs, you should access your images like:
asset('storage/users/userX/file.png');
, notpublic/users/userX/file.png
as you are using.