ckeditor文件上传并在dcat中使用

去掉预览中的文字
# 为了去掉预览中的文字
在ckeditor/plugins/image/dialogs/image.js
搜索“d.config.image_previewText”,把(d.config.image_previewText||)加粗的内容全删了。
开启上传功能
在ckeditor/plugins/image/dialogs/image.js
搜索:id:’Upload’,hidden:!0
实际上上传功能被隐藏了,把上面的!0改成false
定义上传文件时的action
config.filebrowserUploadUrl = '/index.php?action=address&do=upload'; //地址自定义
在php处理文件中加入upload方法;
 $name = 'upload'; if ($request->hasFile($name)){ //获取文件
 $file = $request->file($name); $time = date('Ymd',time()); // 文件是否上传成功
 if ($file->isValid()) { // 获取文件相关信息
 $originalName = $file->getClientOriginalName(); // 文件原名
 $ext = $file->getClientOriginalExtension();     // 扩展名
 $realPath = $file->getRealPath();   //临时文件的绝对路径
 $type = $file->getClientMimeType();     // image/jpeg // 上传文件
 $filename = uniqid() . '.' . $ext; $path = 'editor/'.$time.'/'.$filename; //这里的uploads是配置文件的名称
 $bool = Storage::disk('admin')->put('/'.$path, file_get_contents($realPath)); //判断是否创建成功
 if (!$bool) return response()->json([ 'uploaded' => 0, 'error' => '上传失败',
 ]); return response()->json([ 'uploaded' => 1, "fileName" => $filename, "url" => '/upload/'.$path ]); } } return response()->json([ 'uploaded' => 0, 'error' => '上传失败',
 ]);```

##### bootstrap中引用
> 注册前端组件别名
```php
//(/dcat/editor/ 即你ckeditor存放目录,
//这里放在了,public/dcat/editor/ckeditor)
Admin::asset()->alias('@ckeditor', [
 'js' => [ '/dcat/editor/ckeditor/ckeditor.js', '/dcat/editor/ckeditor/adapters/jquery.js', ],]);
本作品采用《CC 协议》,转载必须注明作者和本文链接
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!