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 协议》,转载必须注明作者和本文链接
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

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