laravel-admin上传图片

在控制中加入
$form->multipleImage(‘file‘, __(‘File‘))->removable();
其中multipleImage是多图上传的标识.
我在数据表中的字段是 file 数据类型是 varchar 所以在model 中 加入 方法名 get/set->后面的File对应字段的名字 首字母大写
public function getFileAttribute($value)
{
return explode(‘,‘, $value);
}

public function setFileAttribute($value)
{
$this->attributes[‘file‘] = implode(‘,‘, $value);
}

config/filesystems中配置(修改disks)
‘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‘,
],
],

laravel-admin上传图片

上一篇:vue发送ajax请求与跨域问题


下一篇:kubernetes集群搭建总结