TinyMCE 4.2 - Get the new (core) Image Tools to save (API) edited images as files?

后端 未结 2 723
情话喂你
情话喂你 2021-01-06 18:54

I am sorry if this is a duplicate. I haven\'t found any question related to this yet:

The new TinyMCE 4.2 Image Tools saves images as base64 data in stead o

相关标签:
2条回答
  • 2021-01-06 19:31

    My code, it's works! If you modify the image and click confirm button then Image Tools will upload the new image to server automatic.

    images_upload_handler: function(blobInfo, success, failure) {
                var xhr, formData;
    
                xhr = new XMLHttpRequest();
                xhr.withCredentials = false;
                xhr.open('POST', 
    '<%=request.getContextPath()%>/fylerMedia?flyerID=<%=flyerID %>'); <<<<note that you must set your server-side upload hander.
    
    
                xhr.onload = function() {
                  var json;
    
                  if (xhr.status != 200) {
                    failure('HTTP Error: ' + xhr.status);
                    return;
                  }
    
                  json = JSON.parse(xhr.responseText);
    
                  success(json[0].url); <<<<<return value, you can change the url of image.
                };
    
                formData = new FormData();
                formData.append('file', blobInfo.blob(), blobInfo.filename());
    
                xhr.send(formData);
            }
    

    Hope it helps you!

    0 讨论(0)
  • 2021-01-06 19:33

    You have to initiate the upload by invoking the

    uploadImages()
    

    method. see http://www.tinymce.com/wiki.php/api4:method.tinymce.Editor.uploadImages

    0 讨论(0)
提交回复
热议问题