1. 在IE9下,我单独用文件上传组件,上传成功无法返回,一直停在“正在上传,请稍后”。
2. 由于用struts,有拦截。用自己写的servlet作文件上传。返回数据为:
其中:revalue的值为:{error:'0',url:'....'}
resp.setContentType("application/json;charset=UTF-8");
resp.setHeader("Cache-Control", "no-store"); //HTTP1.1
resp.setHeader("Pragma", "no-cache"); //HTTP1.0
resp.setDateHeader("Expires", 0);
//System.out.println("getParameterNames----="+req.getParameterNames());
PrintWriter printWriter = resp.getWriter();
printWriter.write(reValue);
printWriter.flush();
printWriter.close();
<script>
KindEditor.ready(function(K) {
var editor = K.editor({
basePath:"<%=request.getContextPath() %>/kindeditor/",
uploadJson : '<%=request.getContextPath() %>/mediaUpload/demo.html',///用htm作为后缀名主要掉过struts2过滤器,
allowFileManager : false
});
K('#uploadbutton').click(function() {
editor.loadPlugin('insertfile', function() {
editor.plugin.fileDialog({
formatUploadUrl : K('#fileurl').val(),
clickFn : function(url, title, width, height, border, align) {
var html="<tr><td class='formtdlabel' align='left'><a href='"+url+"' target='_blank'>"+ title +"</a> </td><td></td></tr>";
//$("#divfileurl").append(html);
//$("#filenames").val($("#filenames").val()+","+url+"|"+title);
document.getElementById("divfileurl").innerHTML +="<a href='"+url+"' target='_blank'>"+ title +"</a> ";
document.getElementById("filenames").value+=","+url+"|"+title;
attachement = new Object();
attachement.url=url;
attachement.title=title;
attachments[updateNumber]=attachement;
updateNumber+=1;
editor.hideDialog();
}
});
});
});
});
</script>
<input type="hidden" id="filenames" value="" />
<input type="button" id="uploadbutton" value="Upload" class="button"/>
<div id="divfileurl">
</div>