How to add a field to POST values in CKeditor upload

后端 未结 6 1867
清歌不尽
清歌不尽 2020-12-31 21:21

I use django and ckeditor to provide wysiwyg taste to TextEdits. I would like to use CKEditor file upload function (in filebrowser / image dialog), but the

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-31 21:58

    It seems that there is no way to add data to ckeditor upload data without editing ckeditor source code. The source code to be modified is plugins/dialogui/plugin.js, around lines 1440 in ckeditor 3.6.2, where ckeditor creates the form used by the upload iframe.

    // ADDED TO CKEDITOR CODE %<
    var csrfitems = document.getElementsByName("csrfmiddlewaretoken")
    var csrftoken = ""
    if(csrfitems.length > 0)
        csrftoken = csrfitems[0].value
    // >% END OF ADDED CODE
    if ( elementDefinition.size )
        size = elementDefinition.size - ( CKEDITOR.env.ie  ? 7 : 0 );   // "Browse" button is bigger in IE.
    frameDocument.$.write( [ '',
    '
    ', // ADDED TO CKEDITOR CODE '', // >% END OF ADDED CODE '', '
    ',

    And now we can use safely upload in ckeditor with django

提交回复
热议问题