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

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

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

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

@Override
	public 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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值