CKEditor 4.5.0 BETA fileUpload API issue

I'm trying CKEditor 4.5.0 BETA because it allows me to paste images from the clipboard to all browsers, but I can't find any documentation regarding the file upload API (new?), An example in This link uses CKFinder but I don't have it , I need to create my own server side code in PHP (I am using Larevel 4 ).

When I try to upload a file, the only parameter in the request is the file (named "upload"), how do I bind the CKEditor instance to my server? maybe something is missing?

CKEDITOR.replace('newticket', {
            extraPlugins    : 'uploadimage,image2',
            uploadUrl       : '/ckeditor/newticket/uploads',

            height                  : '200px',
            toolbar                 : [
                { name: 'clipboard', items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
                { name: 'basicstyles', items: [ 'Bold', 'Italic', 'Underline' ] },
                { name: 'lists', items: [ 'NumberedList', 'BulletedList', 'Outdent', 'Indent', 'Blockquote' ] },
                { name: 'insert', items: ['Link', '-', 'HorizontalRule'] },
                { name: 'font', items: [ 'Format', '-', 'TextColor', 'BGColor'] }
            ]
        });

      

EDIT 1

I am using this code on my server side (Laravel 4), the file is loaded and CKeditor displays a message that the file has loaded correctly, but it does not add the img tag to the document

public function uploadFilesFromCKeditor() {

    if(Input::hasFile('upload')) {

        $fileName = sha1(time() . Input::file('upload')->getClientOriginalName()) . '.' . Input::file('upload')->getClientOriginalExtension();

        $success = Input::file('upload')->move(public_path() . '/ckeditor/uploads', $fileName);

        if($success) {

            $jsonResponse = array(
                'fileName'  => $fileName,
                'url'       => 'ckeditor/uploads/' . $fileName,
                'uploaded'  => 'true',
                'error'     => array(
                    'message'   => ''
                )
            );

        } else {

            $jsonResponse = array(
                'fileName'  => Input::file('upload')->getClientOriginalName(),
                'url'       => '',
                'uploaded'  => 'false',
                'error'     => array(
                    'message'   => 'Error msg'
                )
            );

        }

        return Response::json($jsonResponse);

    } else {

        $jsonResponse = array(
            'fileName'  => '',
            'url'       => '',
            'uploaded'  => 'false',
            'error'     => array(
                'message'   => 'error msg'
            )
        );

        return Response::json($jsonResponse);

    }

}

      

ckeditor message

+3


source to share


1 answer


Since this feature is in beta at the moment, a complete tutorial has yet to be created, but you should be able to handle it based on event documents.

If you receive a request with a single record upload

that contains a file then you are on a good track, this is the default request that is sent. If you want to change it use fileUploadRequest

event
.



CKEditor expects to receive JSON as a response, so all you have to do on the server side is save the file (using a PHP function move_uploaded_file

, see http://php.net/manual/en/features.file-upload.php ) and return ( echo

) the JSON data.

You can find the expected JSON response format and an example of how to handle any other response here .

+3


source







All Articles