首页 > Web开发 > 详细

laravel-admin上传图片

时间:2020-06-18 22:02:54      阅读:73      评论:0      收藏:0      [点我收藏+]

在控制中加入
$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上传图片

原文:https://www.cnblogs.com/ForAll-I-Care/p/13159928.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!