作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用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;
}
}
在我的public文件夹中,有/uploads/images/文件夹。
但是当我想保存项目时,出现以下错误:
InvalidArgumentException in FilesystemManager.php line 121:
Driver [] is not supported.
我的 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',
'root' => public_path('uploads'),
],
或将您的 $disk
变量重命名为另一个磁盘:
public function setImageAttribute($value)
{
$attribute_name = "image";
//Uploads disk for example
$disk = "uploads";
关于php - 不支持驱动程序 []。 - 拉拉维尔 5.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42468245/
我正在使用 git clone 部署我的 Laravel 项目并使用 git pull 进行更新 它工作正常,但每次部署时,我都必须从 config/app.php providers 数组和 ali
我是一名优秀的程序员,十分优秀!