CKEditor Upload Adapter Sends [object Promise] to Server
Reason for your problem is that in version 11.0.0 of ckeditor5-upload plugin the API was changed, loader.file
is now a Promise
(see release notes). Unfortunately the docs were not updated accordingly.
You need to adjust your upload function a little:
upload() { return this.loader.file .then( uploadedFile => { return new Promise( ( resolve, reject ) => { const data = new FormData(); data.append( 'upload', uploadedFile ); axios( { url: '/index/uploadimage', method: 'post', data, headers: { 'Content-Type': 'multipart/form-data;' }, withCredentials: false } ).then( response => { if ( response.data.result == 'success' ) { resolve( { default: response.data.url } ); } else { reject( response.data.message ); } } ).catch( response => { reject( 'Upload failed' ); } ); } ); } );}
The docs that had this issue are now fixed and use promise properly. Hope this solves the problem for you!
Use jQuery ajax. I cannot find an equivalent using fetch or axios. The key is setting contentType: false and processData: false.
upload() { return new Promise((resolve, reject) => { const data = new FormData(); data.append('postedFile', this.loader.file); $.ajax({ url: '/index/uploadimage', data, contentType: false, processData: false, type: 'POST', success: response => { resolve({ default: response.data.url }); }, error: () => { reject('Upload failed'); } }); }); }