官网文档:http://java.fckeditor.net/index.html
CKEditor 3开启文件上传功能(Servlet实现):http://blog.sina.com.cn/s/blog_3fed3a390100hwni.html
评:
1. <span style="font-family: Arial, Verdana, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); ">我所用的FCKEditor 是 fckeditor-java-demo-2.4.zip压缩包</span>
源文件:fckeditor-java-2.4-src.zip
看了一下FCKEditor代码,FCKEditor 多用户上传路径实现其实非常简单。
一、实现net.fckeditor.requestcycle包下两个接口 UserPathBuilder
其中UserPathBuilder这个接口有这样个函数
public String getUserFilesPath(HttpServletRequest request)
是取自定义路径的
UserAction这个接口是验证用户是否有权浏览与上传。这个不多说,自己去实现。
1. public class UserPathBuilderImpl implements
2.
3. // 虚拟目录设置
4. //实际的路径
5. public
6.
7.
8. new
9.
10. // 获得定义connector.userFilesPath的值
11. "connector.userFilesPath");
12. userFilesPathBuffer.append(path);
13. "/");
14.
15. CurrentUser user = (CurrentUser) request.getSession().getAttribute(
16. "user");
17. "userDefault";
18. if (user != null) {
19. userPath = String.valueOf(user.getId());
20. }
21. userFilesPathBuffer.append(userPath);
22.
23. return
24. }
25.
26. // FCK目录设置
27. //读取的路径
28. public
29.
30. new
31. String context = request.getContextPath();
32. userFilesPathBuffer.append(context);
33. // 获得定义connector.userFilesPath的值
34. "connector.userFilesPath");
35. userFilesPathBuffer.append(path);
36. "/");
37.
38. CurrentUser user = (CurrentUser) request.getSession().getAttribute(
39. "user");
40. "userDefault";
41. if (user != null) {
42. userPath = String.valueOf(user.getId());
43. }
44. userFilesPathBuffer.append(userPath);
45.
46. return
47.
48. }
49. }
二、修改你工工程src目录下fckeditor.properties这个文件
将connector.userActionImpl与connector.userPathBuilderImpl这个属性修改成你实现了这两个接口的全类名
1. connector.userActionImpl=net.fckeditor.requestcycle.impl.EnabledUserAction
2. connector.userPathBuilderImpl=com.ids.project.knowledge.action.UserPathBuilderImpl
3. connector.userFilesPath =/userfiles