CKEditor 4.5 filetools, how to set XHR.withCredentials = true,

In CKEditor 4.5 beta, the filetools plugin cannot set cookies when using the cross-domain URL, since CORS allows cookies, which we must set XHR.withCredentials = true when loading XHR.

How to set XHR properties in filetools plugin in CKEditor 4.5.

+4
source share
2 answers

You can access the XHR object by listening to the fileUploadRequest event , and then you can set the flag withCredentialsto true.

editor.on( 'fileUploadRequest', function( evt ) {
    var xhr = evt.data.fileLoader.xhr;

    xhr.withCredentials = true;
} );

A working development sample is available here .

+3
source

To the extension of the answer Adelura.

 editor.on( 'fileUploadRequest', function( event ) {
      var fileLoader = event.data.fileLoader;
      fileLoader.xhr.withCredentials = true;
 }, null, null, 100);

, XHR XHR. filetools , 5 999 .

editor.on( 'fileUploadRequest', function( evt ) {
                var fileLoader = evt.data.fileLoader;

                fileLoader.xhr.open( 'POST', fileLoader.uploadUrl, true );
            }, null, null, 5 );

            editor.on( 'fileUploadRequest', function( evt ) {
                var fileLoader = evt.data.fileLoader,
                    formData = new FormData();

                formData.append( 'upload', fileLoader.file, fileLoader.fileName );
                fileLoader.xhr.send( formData );
            }, null, null, 999 );

, 5 999

0

All Articles