2017-02-26 127 views
2

我使用backpackforlaravel建立自己的网站的后台区域。我在我的ProjectCrudController增加了一个像场:不支持Driver []。 - Laravel 5.3

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

在我的模型项目我有一个突变这样的:

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; 
    } 
} 

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

但是,当我要救一个项目,我发现了以下错误:

InvalidArgumentException in FilesystemManager.php line 121:

Driver [] is not supported.

enter image description here

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(), 
    ], 

]; 

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

回答

9

这里所定义的$diskpublic_folder

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

但在你filesystem.php你没有public_folder盘

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

'disks' => [ 

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

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

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