ckeditor和ckfinder结合使用时问题的解决办法

来源:互联网 发布:200万网络摄像机一夜 编辑:程序博客网 时间:2024/06/05 03:43

ckeditor是很流行的的文本编辑器,ckfinder是它的补充,为ckeditor提供图片、flash上传功能,在使用它们的过程中,遇到一些问题,记录下来。

1、当上传图片名称是中文时,上传失败。解决办法:在tomcat的配置文件server.xml中,在Connector组件处,加上 URIEncoding="utf-8"。

        2、重复上传同一文件,报错,解决办法,修改FileUploadCommand.java类,在execute方法开始出加上errorCode=0;如下所示:

@Overridepublic void execute(final OutputStream out) throws ConnectorException {if (configuration.isDebugMode() && this.exception != null) {throw new ConnectorException(this.errorCode, this.exception);}try {errorCode=0;String errorMsg = (this.errorCode == 0) ? "" : ErrorUtils.getInstance().getErrorMsgByLangAndCode(this.langCode,this.errorCode, this.configuration);errorMsg = errorMsg.replaceAll("%1", Matcher.quoteReplacement(this.newFileName));String path = "";if (!uploaded) {this.newFileName = "";this.currentFolder = "";} else {path = configuration.getTypes().get(type).getUrl()+ this.currentFolder;}if (this.responseType != null && this.responseType.equals("txt")) {out.write((this.newFileName + "|" + errorMsg).getBytes("UTF-8"));} else {out.write("<script type=\"text/javascript\">".getBytes("UTF-8"));if (checkFuncNum()) {handleOnUploadCompleteCallFuncResponse(out, errorMsg, path);} else {handleOnUploadCompleteResponse(out, errorMsg);}out.write("</script>".getBytes("UTF-8"));}} catch (IOException e) {throw new ConnectorException(Constants.Errors.CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED, e);}}

阅读源代码可以发现,当文件存在时,系统会给这个赋值201,导致出错。

0 0
原创粉丝点击