如何修复Laravel项目中没有上载图像功能的CKeditor [英] How to fix CKeditor not having upload image feature in laravel project
本文介绍了如何修复Laravel项目中没有上载图像功能的CKeditor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的ckeditor没有上传图片功能。我希望该功能可用。
My ckeditor does not have an upload image feature. I'd like the feature to be available. How does one work around that in laravel?
推荐答案
您可以使用 CKFinder
,可以轻松上传和管理多个文件。使用内置的图像编辑器可以裁剪,调整大小,旋转,调整亮度,对比度,饱和度,曝光度和清晰度,以及一些预定义的滤镜预设。
You can use CKFinder
that enables uploading and managing multiple files easily. With the built-in image editor cropping, resizing, rotating, adjusting brightness, contrast, saturation, exposure, and sharpness plus some pre-defined filter presets are available.
<script>
CKEDITOR.replace( 'editor1', {
filebrowserBrowseUrl: '/ckfinder/ckfinder.html',
filebrowserUploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files'
} );
$('.textarea').wysihtml5();
</script>
文档此处
对于laravel:
CKEDITOR.replace('editor1', {
filebrowserUploadUrl: "{{ route('ckeditor.upload', ['_token' => csrf_token() ])}}",
filebrowserUploadMethod: 'form'
});
在您的路线中:
Route::post('images/upload', 'ImageController@upload')->name('ckeditor.upload');
和您的 ImageController
:
public function upload(Request $request)
{
if($request->hasFile('upload')) {
$originName = $request->file('upload')->getClientOriginalName();
$fileName = pathinfo($originName, PATHINFO_FILENAME);
$extension = $request->file('upload')->getClientOriginalExtension();
$fileName = $fileName.'_'.time().'.'.$extension;
$request->file('upload')->move(public_path('images'), $fileName);
$CKEditorFuncNum = $request->input('CKEditorFuncNum');
$url = asset('images/'.$fileName);
$msg = 'Image uploaded successfully';
$response = "<script>window.parent.CKEDITOR.tools.callFunction($CKEditorFuncNum, '$url', '$msg')</script>";
@header('Content-type: text/html; charset=utf-8');
echo $response;
}
}
欢呼!
这篇关于如何修复Laravel项目中没有上载图像功能的CKeditor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文