Skip to content
Advertisement

Lumen: Uploading a file / Disk does not have a configured driver

Lumen 6.3.4 / PHP 7.3.9

Trying to upload a file from form data. Getting this error: Disk [qr_uploads] does not have a configured driver.

bootstrap/app.php

$app->configure('filesystems');
$app->register(IlluminateFilesystemFilesystemServiceProvider::class);

config/filesystems.php

<?php

return [
    'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),
        'permissions' => [
            'file' => [
                'public' => 0664,
                'private' => 0600,
            ],
            'dir' => [
                'public' => 0775,
                'private' => 0700,
            ],
        ],
    ],
    'qr_uploads' => [
        'driver' => 'local',
        'root' => storage_path('qr_uploads'),
        'permissions' => [
            'file' => [
                'public' => 0664,
                'private' => 0600,
            ],
            'dir' => [
                'public' => 0775,
                'private' => 0700,
            ],
        ],
    ]
];

controller.php

$upFile = $request->file('uploading');    
$storedPath = $upFile->store('e_'.$entityId, 'qr_uploads');

Getting the aforementioned error. Directory app/storage/qr_uploads exists and is writable. Any ideas?

Advertisement

Answer

Unfortunately, the Laravel/Lumen docs are too fizzy about the configuration file. The correct config/filesystems.php file should include “disks” property:

<?php

return [
    'disks' => [
        'local' => [...]
]

That’s one thing. The other thing related to Lumen (I am not sure about Laravel) – you have to install the Flysystem dependency explicitly!

composer require league/flysystem

Sometime I really wish Lumen/Laravel docs were somewhat specific with the details like this. :/

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement