如何修改fckeditor的图片上传目录

本文介绍如何在FCK编辑器中自定义图片上传路径,通过修改特定的配置文件及使用PropertiesLoader类的方法来实现个性化设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

fck默认的图片上传路径是在fckeditor-java-core.jar的net.fckeditor.handles包下的default.properties中定义的,内如如下:
# base directory for the user files relative to the context root
connector.userFilesPath = /userfiles

fck是在net.fckeditor.handlers包中的PropertiesLoader类中声明了一个static的properties来一次性读入所有的配置的
这是个静态的属性,而且提供了修改的权限
    /**
     * Setter for a property. If the property already exists, the value will be
     * overridden.<br />
     * <em>Hint</em>: This method is intended as an alternative way to set
     * properties programmatically instead of using the
     * <code>fckeditor.properties</code>. It should never used inside
     * FCKeditor.Java!!!
     * 
     * 
@param key
     *            The property key.
     * 
@param value
     *            The property value.
     * 
@see Properties#setProperty(String, String)
     
*/
    
public static void setProperty(final String key, final String value) {
        properties.setProperty(key, value);
    }
所以只需要在fck加载之前修改他既可,比如可以修改fck的例子如下:
String userCode="xxx";//此处可以获取登录用户code等动态代码
PropertiesLoader.setProperty("connector.userFilesPath","/aaaa"+userCode);
fckEditor.setValue(
"This is some <strong>sample text</strong>. You are using <a href=/"http://www.fckeditor.net/">FCKeditor</a>.");
out.println(fckEditor);
这样会生成aaaxxx文件夹
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值