Driver [] is not supported. - Laravel 5.3

nielsv picture nielsv · Feb 26, 2017 · Viewed 46.2k times · Source

I'm using backpackforlaravel to set up the backend area of my website. I've added an image field in my ProjectCrudController:

$this->crud->addField([
    'label' => "Project Image",
    'name' => "image",
    'type' => 'image',
    'upload' => true,
], 'both');

In my Model Project I have a mutator like this:

public function setImageAttribute($value)
{
    $attribute_name = "image";
    $disk = "public_folder";
    $destination_path = "uploads/images";

    // if the image was erased
    if ($value==null) {
        // delete the image from disk
        \Storage::disk($disk)->delete($this->image);

        // set null in the database column
        $this->attributes[$attribute_name] = null;
    }

    // if a base64 was sent, store it in the db
    if (starts_with($value, 'data:image'))
    {
        // 0. Make the image
        $image = \Image::make($value);
        // 1. Generate a filename.
        $filename = md5($value.time()).'.jpg';

        // 2. Store the image on disk.
        \Storage::disk($disk)->put($destination_path.'/'.$filename, $image->stream());
        // 3. Save the path to the database
        $this->attributes[$attribute_name] = $destination_path.'/'.$filename;
    }
}

In my public folder I have /uploads/images/ folder.

But when I want to save a Project I'm getting the following error:

InvalidArgumentException in FilesystemManager.php line 121:

Driver [] is not supported.

enter image description here

My filesystems.php file in my config folder looks like this:

<?php

return [

    'default' => 'local',

    'cloud' => 's3',

    'disks' => [

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

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

        's3' => [
            'driver' => 's3',
            'key' => 'your-key',
            'secret' => 'your-secret',
            'region' => 'your-region',
            'bucket' => 'your-bucket',
        ],
        'uploads' => [
            'driver' => 'local',
            'root' => public_path('uploads'),
        ],

    ],

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

];

What could be the problem here? I'm using Laravel Homestead version 2.2.2.

Answer

Jo&#227;o Mantovani picture João Mantovani · Feb 26, 2017

Here you defined the $disk as public_folder:

public function setImageAttribute($value)
{
    $attribute_name = "image";
    $disk = "public_folder";
    $destination_path = "uploads/images";

But in your filesystem.php you don't have the public_folder disk

You need to create a new "public_folder" disk

'disks' => [

    'public_folder' => [
        'driver' => 'local',
        'root' => public_path('uploads'),
    ],

or rename your $disk variable to another disk:

public function setImageAttribute($value)
{
    $attribute_name = "image";
    //Uploads disk for example
    $disk = "uploads";