php 不支持驱动程序 []。- Laravel 5.3

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42468245/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:36:22  来源:igfitidea点击:

Driver [] is not supported. - Laravel 5.3

phpimagelaravellaravel-5.3backpack-for-laravel

提问by nielsv

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

我正在使用backpackforlaravel来设置我网站的后端区域。我在ProjectCrudController 中添加了一个图像字段:

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

In my Model ProjectI have a mutatorlike 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 publicfolder I have /uploads/images/folder.

在我的公共文件夹中,我有/uploads/images/文件夹。

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

但是当我想保存一个项目时,我收到以下错误:

InvalidArgumentException in FilesystemManager.php line 121:

Driver [] is not supported.

FilesystemManager.php 第 121 行中的 InvalidArgumentException:

不支持驱动程序 []。

enter image description here

在此处输入图片说明

My filesystems.php filein my configfolder looks like this:

filesystems.php文件在我的配置文件夹,如下所示:

<?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.

这里可能有什么问题?我正在使用Laravel Homestead 版本 2.2.2

回答by Jo?o Mantovani

Here you defined the $diskas public_folder:

在这里,您将其定义$diskpublic_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

但是在你的 filesystem.php 你没有 public_folder 磁盘

You need to create a new "public_folder" disk

您需要创建一个新的“public_folder”磁盘

'disks' => [

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

or rename your $diskvariable to another disk:

或将您的$disk变量重命名为另一个磁盘:

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