Сперва создадим маршут в файле routes/web.php
Routes::post('upload','CKEditorController@upload')->name('upload');
Далее создадим контроллер CKEditorController:
php artisan make:controller CKEditorController
Переходим в него, и добавляем экшн upload:
public function upload(Request $request) { if($request->hasFile('upload')) { if(!Auth::guest()){ $puth_url = $_SERVER['DOCUMENT_ROOT'].'/storage/uploads/' . Auth::user()->id; if (!file_exists($puth_url)) { mkdir($puth_url, 0777, true); } }else{ } //get filename with extension $filenamewithextension = $request->file('upload')->getClientOriginalName(); //get filename without extension $filename = pathinfo($filenamewithextension, PATHINFO_FILENAME); //get file extension $extension = $request->file('upload')->getClientOriginalExtension(); //filename to store $filenametostore = $filename.'_'.time().'.'.$extension; //Upload File $request->file('upload')->storeAs('public/uploads/'.Auth::user()->id, $filenametostore); $CKEditorFuncNum = $request->input('CKEditorFuncNum'); $url = asset('storage/uploads/'.Auth::user()->id.'/'.$filenametostore); $msg = 'Image successfully uploaded'; $re = "<script>window.parent.CKEDITOR.tools.callFunction($CKEditorFuncNum, '$url', '$msg')</script>"; // Render HTML output @header('Content-type: text/html; charset=utf-8'); echo $re; } }