G
G
Givi7772019-08-20 16:23:18
Laravel
Givi777, 2019-08-20 16:23:18

Problem with uploading image to CKEditor 5 server?

var elementId = "desc_comp";
    ClassicEditor
        .create(document.getElementById(elementId), {
            toolbar: ['bold', 'italic', 'bulletedList', 'numberedList', '|', 'link', '|', 'imageUpload', '|', 'undo', 'redo'],
            ckfinder: {
                uploadUrl: 'uploads/ckeditor',
                options: {
                    resourceType: 'Images',
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                }
            }
        })
        .then(editor => {
            editor[elementId] = editor;
        })
        .catch(err => console.error(err.stack));

controller
<?php
namespace App\Http\Controllers\Administrator;

use App\Http\Controllers\Controller;

class ImagesController extends Controller
{
    public function upload(Request $request){
        $path  = $request->file('image')->store("uploads", 'public');
        return response()->json(array(
            'file' => url('/storage/'. $path),
            'success' => 1,
            'status' => 200,
        ));
    }
}

route
Route::post('image/upload', '[email protected]')->name('image.upload');

5d5bf40a55248887920286.png
5d5bf411b297e947764886.png
sudo chmod -R 777 public/uploads/ckeditor/
doesn't work...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
deverlines, 2019-08-24
@deverlines

Ckeditor makes a GET request.
And the route says Route:: post ('image/upload', '[email protected]')->name('image.upload');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question