2017-02-26 125 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";