Problem serving stored file in local

Posted 1 year ago by jahstation

I've a form that upload even some files for user in a personal user's folder. I've done that with code like:

if(! Storage::disk('public')->has("users/".$username."_".Auth::user()->id))
{
                Storage::makeDirectory("public/users/".$username."_".Auth::user()->id);
 }
$patz="public/users/".$username."_".Auth::user()->id;
$now= new \Carbon\Carbon();
$fileName = 'ddt_'.$username."_".$now->toAtomString().'.'.$request->ddt_file->getClientOriginalExtension();
  $pathComplete=$request->ddt_file->storeAs($patz,$fileName);

then i save the url in db table for having it ready to serve!

This save my files on: /storage/app/local/users/USERX/fileX_date_.originalextension

Then i made a sym link with the instruction php artisan storage:link

But then there is no way to show this file to front end! On my config/filesystem.php there is:

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

when im using commands like: $url=Storage::url('users/USERX/FILEx.png'); the result is a string like: /storage/users/USERX/fileX.png if i put it in assett() function not works!

where I wrong?

Please sign in or create an account to participate in this conversation.