GotExx's avatar

The storage path of an image is false in relation to its real location.

Hello, I want to upload an image to my application's storage system, in the public folder.

So I have this:

filesystem.php

'disks' => [

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

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

    's3' => [
        'driver' => 's3',
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'region' => env('AWS_DEFAULT_REGION'),
        'bucket' => env('AWS_BUCKET'),
        'url' => env('AWS_URL'),
        'endpoint' => env('AWS_ENDPOINT'),
    ],

],

The image can be found in /storage/app/public but the path returned by $request->banner->path(); is like "/tmp/php4kmenF".

This is my controller:

public function storePublicBanner(Request $request)
{
            
    $validatedData = $request->validate(['banner' => 'required|mimes:jpeg,png|max:8192',]);
    
    
    $request->banner->store('banners', 'public');    
    
    if ($request->banner->isValid()) {
        $user = User::find($request->user()->steam_id);
        
        dd($request->banner->path());
    
        $user->banner = $request->banner->path();
        
        $user->save();
    }
    
    return redirect('dashboard')->with('status', 'Banner saved !');
   
}

Am I missing something?

0 likes
1 reply

Please or to participate in this conversation.