【发布时间】:2016-04-11 20:52:02
【问题描述】:
我在Handling Async Image Upload 中使用 Servlet 作为后端使用 TinyMCE 时遇到了问题。
主要有两个问题:
-
1234563仅此而已。
粘贴图片后,TinyMCE 应该异步上传它们并将
<img>的src属性更新为location属性,该属性由后端json返回。
现在问题出现在这里,当我单独粘贴图像时,它会自动上传到后端,并且正确的响应会以图像的location 作为 JSON 返回,我已经通过浏览器控制台以及手动图像插入选项验证了这一点.但毕竟<img scr> 是空白的,图像变成了黑色边界。
如果有人遇到过类似的问题,请帮助我,而后端可以是任何东西,因为我认为这不是后端的问题。
代码:
TinyMCE:
<script type="text/javascript" charset="utf-8">
tinymce.init({
selector: '#description',
plugins: "image link imagetools codesample emoticons autoresize textcolor table preview wordcount paste",
menubar: 'edit | format | insert | table',
toolbar1: 'undo redo | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
toolbar2: 'forecolor backcolor | codesample emoticons',
automatic_uploads: true,
images_upload_url: 'uploadFile',
images_upload_credentials: true,
images_upload_base_path: '',
paste_data_images: true,
file_browser_callback_types: 'image',
convert_urls: false,
file_browser_callback: function(field_name, url, type, win) {
tinymce.activeEditor.windowManager.open({
title: "File Browser",
type: "image",
url: "uploadFile",
width: 550,
height: 200
}, {
oninsert: function(url) {
win.document.getElementById(field_name).value = url;
}
});
}
});
</script>
Back end Response after image upload:
[{ "location": "./uploaded/images/201617175645_blobid0.png" }]
<img> tag after image upload:
<img src="" alt="" data-mce-src="" data-mce-selected="1">
Chrome 控制台在粘贴图像或上传图像后完全不显示异常或警告。请让我知道是否有人对问题有任何解决方案或以某种方式了解其背后的实际原因。让我知道上面是否需要更多解释。
【问题讨论】:
标签: jquery html image servlets tinymce