CKFinder baseDir 和 baseURL参数解释

来源:互联网 发布:淘宝美工岗位认识 编辑:程序博客网 时间:2024/06/11 13:58

版本 ckfinder 2.x

一、概念

参考官网解释(如果访问不了,可以点击最新的官方地址)

Both baseDir and baseURL should point to the same location on the
server — the userfiles directory that contains all user files uploaded
with CKFinder. The difference between them is as follows:

  • baseURL gives a full URL to the userfiles directory or a path that is relative to the domain. For example:
    <baseURL>http://example.com/CKFinderJava/userfiles/</baseURL>
    <baseURL>/CKFinderJava/userfiles/</baseURL>
  • baseDir gives an absolute path to the directory on the server (a physical machine). For example:
    <baseDir>/usr/tomcat/webapps/CKFinderJava/userfiles/</baseDir>
    <baseDir>C:\tomcat\webapps\CKFinderJava\userfiles\</baseDir>

也就是说,baseDir是上传文件目录在服务器中的绝对路径,baseURL是一个浏览器的访问路径(可以使用相对路径).

二、配置

baseDir跟baseURL其实都是指向同一个文件目录,但为什么配置了baseURL之后一般情况下也需要配置baseDir参数?这是因为服务器配置原因导致有可能根据baseURL找不到路径而出现故障,这个时候baseDir就能派上用场了,因为它是一个绝对路径,所以不受服务器配置的影响.

三、最佳实践

1.it is always recommended to set both baseUrl and baseDir so that they point to same location which is outside of an application
directory.
2.First of all you should set both properties so that they point to same location which is accessible through HTTP and from the file
system. Second, you should set these properties to point to location
outside of CKFinder application folder.

baseUrl 、baseDir 指向相同的地方,并且最好把文件上传的目录指向应用程序目录的外面.为什么呢?如果不这样做的话,每次升级系统重新发布war包都会覆盖原来的文件上传目录.有什么解决方法呢?可以设置虚拟目录或者符号连接(不推荐,每次发布都要新建符号连接)。如下配置

tomcat 6
在 server.xml文件中增加一个context .

tomcat 7-8
CKFinder config.xml settings:

<baseDir>C:/myimages</baseDir>

<Context antiJARLocking="true" path="/CKFinderJava" reloadable="true" >    <Resources>       <PreResources base="C://myimages" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/userfiles" />   </Resources>   <Valve className="org.apache.catalina.valves.RemoteAddrValve"  allow=".*" /></Context>

参考资料:

1.baseDir and baseURL Parameters Explained
2.ckeditor

原创粉丝点击