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
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!
You have to initiate the upload by invoking the
uploadImages()
method. see http://www.tinymce.com/wiki.php/api4:method.tinymce.Editor.uploadImages