laravel-admin上传图片
2021-02-03 08:15
标签:数据 aws storage cal fun 方法 disk function filesyste 在控制中加入 public function setFileAttribute($value) config/filesystems中配置(修改disks) laravel-admin上传图片 标签:数据 aws storage cal fun 方法 disk function filesyste 原文地址:https://www.cnblogs.com/ForAll-I-Care/p/13159928.html
$form->multipleImage(‘file‘, __(‘File‘))->removable();
其中multipleImage是多图上传的标识.
我在数据表中的字段是 file 数据类型是 varchar 所以在model 中 加入 方法名 get/set->后面的File对应字段的名字 首字母大写
public function getFileAttribute($value)
{
return explode(‘,‘, $value);
}
{
$this->attributes[‘file‘] = implode(‘,‘, $value);
}
‘disks‘ => [
‘local‘ => [
‘driver‘ => ‘local‘,
‘root‘ => storage_path(‘app‘),
],
‘public‘ => [
‘driver‘ => ‘local‘,
‘root‘ => storage_path(‘app/public‘),
‘url‘ => env(‘APP_URL‘).‘/storage‘,
‘visibility‘ => ‘public‘,
],
‘s3‘ => [
‘driver‘ => ‘s3‘,
‘key‘ => env(‘AWS_KEY‘),
‘secret‘ => env(‘AWS_SECRET‘),
‘region‘ => env(‘AWS_REGION‘),
‘bucket‘ => env(‘AWS_BUCKET‘),
],
‘admin‘ => [
‘driver‘ => ‘local‘,
‘root‘ => public_path(‘upload‘),
‘visibility‘ => ‘public‘,
‘url‘ => env(‘APP_URL‘).‘/upload/‘,
],
],
需要在config/admin中配置(修改upload中的数据)
‘upload‘ => [
// Disk in `config/filesystem.php`.
‘disk‘ => ‘admin‘,
// Image and file upload path under the disk above.
‘directory‘ => [
‘image‘ => ‘images‘,
‘file‘ => ‘files‘,
],
],
下一篇:kubernetes集群搭建总结