php – 不支持Driver []. – Laravel 5.3
发布时间:2020-12-14 19:41:34 所属栏目:大数据 来源:网络整理
导读:我正在使用 backpackforlaravel来设置我网站的后端区域.我在ProjectCrudController中添加了一个图像字段: $this-crud-addField([ 'label' = "Project Image",'name' = "image",'type' = 'image','upload' = true,],'both'); 在我的模型项目中,我有一个像这
我正在使用
backpackforlaravel来设置我网站的后端区域.我在ProjectCrudController中添加了一个图像字段:
$this->crud->addField([ 'label' => "Project Image",'name' => "image",'type' => 'image','upload' => true,],'both'); 在我的模型项目中,我有一个像这样的mutator: 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 /文件夹. 但是,当我想保存项目时,我收到以下错误:
我的config文件夹中的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版.
在这里,您将$disk定义为public_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', 或者将$disk变量重命名为另一个磁盘: public function setImageAttribute($value) { $attribute_name = "image"; //Uploads disk for example $disk = "uploads"; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |