Posted on 2010-08-11 12:06
asdtiang 阅读(1051)
评论(5) 编辑 收藏 所属分类:
grails study
fckeditor插件的安装就不用多说了,在使用时有时会出现上传图片显示的情况,
config配置如下:
appName='tatu'///为项目的名称
// set per-environment serverURL stem for creating absolute links
environments {
production {
grails.serverURL = "http://www.changeme.com"
}
development {
grails.serverURL = "http://localhost:8080/${appName}"
}
test {
grails.serverURL = "http://localhost:8080/${appName}"
}
} fckeditor {
upload {
basedir = "uploads/" ///配置上传目录
baseurl = "${grails.serverURL}/uploads/"////配置访问路径
overwrite = false
link {
browser = false
upload = true
allowed = []
denied = ['html', 'htm', 'php', 'php2', 'php3', 'php4', 'php5',
'phtml', 'pwml', 'inc', 'asp', 'aspx', 'ascx', 'jsp',
'cfm', 'cfc', 'pl', 'bat', 'exe', 'com', 'dll', 'vbs', 'js', 'reg',
'cgi', 'htaccess', 'asis', 'sh', 'shtml', 'shtm', 'phtm']
}
image {
browser = true
upload = true
allowed = ['jpg', 'gif', 'jpeg', 'png']
denied = []
}
flash {
browser = false
upload = false
allowed = ['swf']
denied = []
}
media {
browser = false
upload = false
allowed = ['mpg', 'mpeg', 'avi', 'wmv', 'asf', 'mov']
denied = []
}
}
}
有时会遇到上传了,显示不了,查看一下上传文件没有在项目文件夹下面,这里可以改源码:
找到FckeditorController的execute方法
private execute(command, currentFolder, userSpace, uploadOnly = false) {
def config = grailsApplication.config.fckeditor
def baseDir = config.upload.basedir ?: Fckeditor.DEFAULT_BASEDIR
baseDir = PathUtils.checkSlashes(baseDir, "L+ R+", true)
baseDir=servletContext.getRealPath("/") +baseDir //////增加这句就可以了
def spaceDir = PathUtils.sanitizePath(userSpace)
spaceDir = PathUtils.checkSlashes(spaceDir, "L- R+", true)
def type = params.Type
def currentPath = "${baseDir}${spaceDir}${type}${currentFolder}"
def currentUrl
def realPath 天苍苍,野茫茫,风吹草底见牛羊