1 year ago

Laravel storing images outside public directory

Posted 1 year ago by Charrua

Hello, I'm trying to store images using the local driver. I have followed docs and created the symbolic link php artisan storage:link

I'm saving a file from a form and in my controller I have the following: $communication->image = Storage::putFile('messages', $request->file('image'));

The problem is that this is creating a directory messages inside storage/app/messages and not in storage/app/public/messages as it should.

My ┬┤config/filesystems.php` is:

return [

    'default' => env('FILESYSTEM_DRIVER', 'local'),

    'cloud' => env('FILESYSTEM_CLOUD', 's3'),

    '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'),



Any ideas?

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