(一)fckeditor控件表情修改
fckconfig.js中的后面几个参数控制表情,你可以将下面几个参数拷贝到myconfig.js,并进行修改就可以了。
FCKConfig.SmileyPath = FCKConfig.BasePath + 'images/smiley/msn/' ; //图片的路径
//图片的名字(数组)
FCKConfig.SmileyImages = ['aa.jpg','regular_smile.gif','sad_smile.gif','wink_smile.gif','teeth_smile.gif','confused_smile.gif','tounge_smile.gif','embaressed_smile.gif','omg_smile.gif','whatchutalkingabout_smile.gif','angry_smile.gif','angel_smile.gif','shades_smile.gif','devil_smile.gif','cry_smile.gif','lightbulb.gif','thumbs_down.gif','thumbs_up.gif','heart.gif','broken_heart.gif','kiss.gif','envelope.gif'] ;
FCKConfig.SmileyColumns = 8 ;// 每行显示的个数
FCKConfig.SmileyWindowWidth = 320 ;//弹出窗口宽度
FCKConfig.SmileyWindowHeight = 210 ;//弹出窗口高度
如果想修改弹出的标签页面可以去fckeditor/editor/dialog/fck_smiley.html文件。
//注释掉下面语句
//dialog.SetAutoSize( true ) ;//根据页面内容的大小,修改当前窗口的合适大小
以及修改下面样式
<!--将style类型更换
<body style="overflow: hidden">
-->
<body style="overflow: auto">
(二)fckeditor控件实现文件文件上传
在web.xml中添加下面配置
<servlet>
<servlet-name>Connector</servlet-name>
<servlet-class>
net.fckeditor.connector.ConnectorServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Connector</servlet-name>
<url-pattern>
/fckeditor/editor/filemanager/connectors/*
</url-pattern>
在src目录下建立文件fckeditor.properties,并输入如下内容
connector.userActionImpl=net.fckeditor.requestcycle.impl.UserActionImpl
重新发布项目,就可以实现服务器文件上传与浏览。
(三)fckeditor控件文件上传中文问题
上面虽然已经实现上传问题,单仍然存在中文乱码问题,具体解决办法如下:
自己新建一个ConnectorServlet,将源代码中原来ConnectorServlet的内容复制过来,并做简单修改。
图片名中文问题,解决方式如下:
(1)在dopost()方法中添加
upload.setHeaderEncoding("utf-8");
(2)在创建文件夹时,也存在中文问题,需要在doget()方法中
String newFolderStr = UtilsFile.sanitizeFolderName(request.getParameter("NewFolderName"));
修改成
String tmpStr=request.getParameter("NewFolderName");
tmpStr=new String(tmpStr.getBytes("iso8859-1"),"utf-8");
String newFolderStr = UtilsFile.sanitizeFolderName(tmpStr);
(3)虽然上面已经可以正常上传中文图片和创建中文文件夹,但是,中文图片却无法正常显示。
这里可以采用如下方式解决问题。上传以后采用其它非中文名称进行保存,这里采用
filename=UUID.randomUUID().toString()+"."+extension;来解决问题;
当然很多网站是采用当前日期生成对应文件名,这个也比较好。
具体代码如下
package jCuckoo;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.fckeditor.connector.Messages;
import net.fckeditor.handlers.CommandHandler;
import net.fckeditor.handlers.ConnectorHandler;
import net.fckeditor.handlers.ExtensionsHandler;
import net.fckeditor.handlers.RequestCycleHandler;
import net.fckeditor.handlers.ResourceTypeHandler;
import net.fckeditor.response.UploadResponse;
import net.fckeditor.response.XmlResponse;
import net.fckeditor.tool.Utils;
import net.fckeditor.tool.UtilsFile;
import net.fckeditor.tool.UtilsResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ConnectorServlet extends HttpServlet {
private static final long serialVersionUID = -5742008970929377161L;
private static final Logger logger = LoggerFactory.getLogger(ConnectorServlet.class);
public void init() throws ServletException, IllegalArgumentException {
String realDefaultUserFilesPath = getServletContext().getRealPath(
ConnectorHandler.getDefaultUserFilesPath());
File defaultUserFilesDir = new File(realDefaultUserFilesPath);
UtilsFile.checkDirAndCreate(defaultUserFilesDir);
logger.info("ConnectorServlet successfully initialized!");
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
logger.debug("Entering ConnectorServlet#doGet");
response.setCharacterEncoding("UTF-8");
response.setContentType("application/xml; charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out = response.getWriter();
String commandStr = request.getParameter("Command");
String typeStr = request.getParameter("Type");
String currentFolderStr = request.getParameter("CurrentFolder");
logger.debug("Parameter Command: {}", commandStr);
logger.debug("Parameter Type: {}", typeStr);
logger.debug("Parameter CurrentFolder: {}", currentFolderStr);
XmlResponse xr;
if (!RequestCycleHandler.isEnabledForFileBrowsing(request))
xr = new XmlResponse(XmlResponse.EN_ERROR, Messages.NOT_AUTHORIZED_FOR_BROWSING);
else if (!CommandHandler.isValidForGet(commandStr))
xr = new XmlResponse(XmlResponse.EN_ERROR, Messages.INVALID_COMMAND);
else if (typeStr != null && !ResourceTypeHandler.isValid(typeStr))
xr = new XmlResponse(XmlResponse.EN_ERROR, Messages.INVALID_TYPE);
else if (!UtilsFile.isValidPath(currentFolderStr))
xr = new XmlResponse(XmlResponse.EN_ERROR, Messages.INVALID_CURRENT_FOLDER);
else {
CommandHandler command = CommandHandler.getCommand(commandStr);
ResourceTypeHandler resourceType = ResourceTypeHandler.getDefaultResourceType(typeStr);
String typePath = UtilsFile.constructServerSidePath(request, resourceType);
String typeDirPath = getServletContext().getRealPath(typePath);
File typeDir = new File(typeDirPath);
UtilsFile.checkDirAndCreate(typeDir);
File currentDir = new File(typeDir, currentFolderStr);
if (!currentDir.exists())
xr = new XmlResponse(XmlResponse.EN_INVALID_FOLDER_NAME);
else {
xr = new XmlResponse(command, resourceType, currentFolderStr, UtilsResponse
.constructResponseUrl(request, resourceType, currentFolderStr, true,
ConnectorHandler.isFullUrl()));
if (command.equals(CommandHandler.GET_FOLDERS))
xr.setFolders(currentDir);
else if (command.equals(CommandHandler.GET_FOLDERS_AND_FILES))
xr.setFoldersAndFiles(currentDir);
else if (command.equals(CommandHandler.CREATE_FOLDER)) {
String tmpStr=request.getParameter("NewFolderName");
tmpStr=new String(tmpStr.getBytes("iso8859-1"),"utf-8");
String newFolderStr = UtilsFile.sanitizeFolderName(tmpStr);
logger.debug("Parameter NewFolderName: {}", newFolderStr);
File newFolder = new File(currentDir, newFolderStr);
int errorNumber = XmlResponse.EN_UKNOWN;
if (newFolder.exists())
errorNumber = XmlResponse.EN_ALREADY_EXISTS;
else {
try {
errorNumber = (newFolder.mkdir()) ? XmlResponse.EN_OK
: XmlResponse.EN_INVALID_FOLDER_NAME;
} catch (SecurityException e) {
errorNumber = XmlResponse.EN_SECURITY_ERROR;
}
}
xr.setError(errorNumber);
}
}
}
out.print(xr);
out.flush();
out.close();
logger.debug("Exiting ConnectorServlet#doGet");
}
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
logger.debug("Entering Connector#doPost");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out = response.getWriter();
String commandStr = request.getParameter("Command");
String typeStr = request.getParameter("Type");
String currentFolderStr = request.getParameter("CurrentFolder");
logger.debug("Parameter Command: {}", commandStr);
logger.debug("Parameter Type: {}", typeStr);
logger.debug("Parameter CurrentFolder: {}", currentFolderStr);
UploadResponse ur;
// if this is a QuickUpload request, 'commandStr' and 'currentFolderStr'
// are empty
if (Utils.isEmpty(commandStr) && Utils.isEmpty(currentFolderStr)) {
commandStr = "QuickUpload";
currentFolderStr = "/";
}
if (!RequestCycleHandler.isEnabledForFileUpload(request))
ur = new UploadResponse(UploadResponse.SC_SECURITY_ERROR, null, null,
Messages.NOT_AUTHORIZED_FOR_UPLOAD);
else if (!CommandHandler.isValidForPost(commandStr))
ur = new UploadResponse(UploadResponse.SC_ERROR, null, null, Messages.INVALID_COMMAND);
else if (typeStr != null && !ResourceTypeHandler.isValid(typeStr))
ur = new UploadResponse(UploadResponse.SC_ERROR, null, null, Messages.INVALID_TYPE);
else if (!UtilsFile.isValidPath(currentFolderStr))
ur = UploadResponse.UR_INVALID_CURRENT_FOLDER;
else {
ResourceTypeHandler resourceType = ResourceTypeHandler.getDefaultResourceType(typeStr);
String typePath = UtilsFile.constructServerSidePath(request, resourceType);
String typeDirPath = getServletContext().getRealPath(typePath);
File typeDir = new File(typeDirPath);
UtilsFile.checkDirAndCreate(typeDir);
File currentDir = new File(typeDir, currentFolderStr);
if (!currentDir.exists())
ur = UploadResponse.UR_INVALID_CURRENT_FOLDER;
else {
String newFilename = null;
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
//此处修改
upload.setHeaderEncoding("utf-8");
try {
List<FileItem> items = upload.parseRequest(request);
// We upload only one file at the same time
FileItem uplFile = items.get(0);
String rawName = UtilsFile.sanitizeFileName(uplFile.getName());
String filename = FilenameUtils.getName(rawName);
String baseName = FilenameUtils.removeExtension(filename);
String extension = FilenameUtils.getExtension(filename);
if (!ExtensionsHandler.isAllowed(resourceType, extension))
ur = new UploadResponse(UploadResponse.SC_INVALID_EXTENSION);
else {
// 将文件名字进行转换,换掉原先中文名字,当然可以采用日期产生文件的名字。
filename=UUID.randomUUID().toString()+"."+extension;
File pathToSave = new File(currentDir, filename);
int counter = 1;
while (pathToSave.exists()) {
newFilename = baseName.concat("(").concat(String.valueOf(counter))
.concat(")").concat(".").concat(extension);
pathToSave = new File(currentDir, newFilename);
counter++;
}
if (Utils.isEmpty(newFilename))
ur = new UploadResponse(UploadResponse.SC_OK, UtilsResponse
.constructResponseUrl(request, resourceType, currentFolderStr,
true, ConnectorHandler.isFullUrl()).concat(filename));
else
ur = new UploadResponse(UploadResponse.SC_RENAMED,
UtilsResponse.constructResponseUrl(request, resourceType,
currentFolderStr, true, ConnectorHandler.isFullUrl())
.concat(newFilename), newFilename);
// secure image check
if (resourceType.equals(ResourceTypeHandler.IMAGE)
&& ConnectorHandler.isSecureImageUploads()) {
if (UtilsFile.isImage(uplFile.getInputStream()))
uplFile.write(pathToSave);
else {
uplFile.delete();
ur = new UploadResponse(UploadResponse.SC_INVALID_EXTENSION);
}
} else
uplFile.write(pathToSave);
}
} catch (Exception e) {
ur = new UploadResponse(UploadResponse.SC_SECURITY_ERROR);
}
}
}
out.print(ur);
out.flush();
out.close();
logger.debug("Exiting Connector#doPost");
}
}
然后将web.xml中的servlet进行修改,具体修改如下:
<servlet>
<servlet-name>Connector</servlet-name>
<servlet-class>
jCuckoo.ConnectorServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Connector</servlet-name>
<url-pattern>
/fckeditor/editor/filemanager/connectors/*
</url-pattern>
</servlet-mapping>
重新部署,发布就可以实现该功能。
转载:http://blog.csdn.net/guoquanyou/article/details/3562052
fckconfig.js中的后面几个参数控制表情,你可以将下面几个参数拷贝到myconfig.js,并进行修改就可以了。
FCKConfig.SmileyPath = FCKConfig.BasePath + 'images/smiley/msn/' ; //图片的路径
//图片的名字(数组)
FCKConfig.SmileyImages = ['aa.jpg','regular_smile.gif','sad_smile.gif','wink_smile.gif','teeth_smile.gif','confused_smile.gif','tounge_smile.gif','embaressed_smile.gif','omg_smile.gif','whatchutalkingabout_smile.gif','angry_smile.gif','angel_smile.gif','shades_smile.gif','devil_smile.gif','cry_smile.gif','lightbulb.gif','thumbs_down.gif','thumbs_up.gif','heart.gif','broken_heart.gif','kiss.gif','envelope.gif'] ;
FCKConfig.SmileyColumns = 8 ;// 每行显示的个数
FCKConfig.SmileyWindowWidth = 320 ;//弹出窗口宽度
FCKConfig.SmileyWindowHeight = 210 ;//弹出窗口高度
如果想修改弹出的标签页面可以去fckeditor/editor/dialog/fck_smiley.html文件。
//注释掉下面语句
//dialog.SetAutoSize( true ) ;//根据页面内容的大小,修改当前窗口的合适大小
以及修改下面样式
<!--将style类型更换
<body style="overflow: hidden">
-->
<body style="overflow: auto">
(二)fckeditor控件实现文件文件上传
在web.xml中添加下面配置
<servlet>
<servlet-name>Connector</servlet-name>
<servlet-class>
net.fckeditor.connector.ConnectorServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Connector</servlet-name>
<url-pattern>
/fckeditor/editor/filemanager/connectors/*
</url-pattern>
在src目录下建立文件fckeditor.properties,并输入如下内容
connector.userActionImpl=net.fckeditor.requestcycle.impl.UserActionImpl
重新发布项目,就可以实现服务器文件上传与浏览。
(三)fckeditor控件文件上传中文问题
上面虽然已经实现上传问题,单仍然存在中文乱码问题,具体解决办法如下:
自己新建一个ConnectorServlet,将源代码中原来ConnectorServlet的内容复制过来,并做简单修改。
图片名中文问题,解决方式如下:
(1)在dopost()方法中添加
upload.setHeaderEncoding("utf-8");
(2)在创建文件夹时,也存在中文问题,需要在doget()方法中
String newFolderStr = UtilsFile.sanitizeFolderName(request.getParameter("NewFolderName"));
修改成
String tmpStr=request.getParameter("NewFolderName");
tmpStr=new String(tmpStr.getBytes("iso8859-1"),"utf-8");
String newFolderStr = UtilsFile.sanitizeFolderName(tmpStr);
(3)虽然上面已经可以正常上传中文图片和创建中文文件夹,但是,中文图片却无法正常显示。
这里可以采用如下方式解决问题。上传以后采用其它非中文名称进行保存,这里采用
filename=UUID.randomUUID().toString()+"."+extension;来解决问题;
当然很多网站是采用当前日期生成对应文件名,这个也比较好。
具体代码如下
package jCuckoo;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.fckeditor.connector.Messages;
import net.fckeditor.handlers.CommandHandler;
import net.fckeditor.handlers.ConnectorHandler;
import net.fckeditor.handlers.ExtensionsHandler;
import net.fckeditor.handlers.RequestCycleHandler;
import net.fckeditor.handlers.ResourceTypeHandler;
import net.fckeditor.response.UploadResponse;
import net.fckeditor.response.XmlResponse;
import net.fckeditor.tool.Utils;
import net.fckeditor.tool.UtilsFile;
import net.fckeditor.tool.UtilsResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ConnectorServlet extends HttpServlet {
private static final long serialVersionUID = -5742008970929377161L;
private static final Logger logger = LoggerFactory.getLogger(ConnectorServlet.class);
public void init() throws ServletException, IllegalArgumentException {
String realDefaultUserFilesPath = getServletContext().getRealPath(
ConnectorHandler.getDefaultUserFilesPath());
File defaultUserFilesDir = new File(realDefaultUserFilesPath);
UtilsFile.checkDirAndCreate(defaultUserFilesDir);
logger.info("ConnectorServlet successfully initialized!");
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
logger.debug("Entering ConnectorServlet#doGet");
response.setCharacterEncoding("UTF-8");
response.setContentType("application/xml; charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out = response.getWriter();
String commandStr = request.getParameter("Command");
String typeStr = request.getParameter("Type");
String currentFolderStr = request.getParameter("CurrentFolder");
logger.debug("Parameter Command: {}", commandStr);
logger.debug("Parameter Type: {}", typeStr);
logger.debug("Parameter CurrentFolder: {}", currentFolderStr);
XmlResponse xr;
if (!RequestCycleHandler.isEnabledForFileBrowsing(request))
xr = new XmlResponse(XmlResponse.EN_ERROR, Messages.NOT_AUTHORIZED_FOR_BROWSING);
else if (!CommandHandler.isValidForGet(commandStr))
xr = new XmlResponse(XmlResponse.EN_ERROR, Messages.INVALID_COMMAND);
else if (typeStr != null && !ResourceTypeHandler.isValid(typeStr))
xr = new XmlResponse(XmlResponse.EN_ERROR, Messages.INVALID_TYPE);
else if (!UtilsFile.isValidPath(currentFolderStr))
xr = new XmlResponse(XmlResponse.EN_ERROR, Messages.INVALID_CURRENT_FOLDER);
else {
CommandHandler command = CommandHandler.getCommand(commandStr);
ResourceTypeHandler resourceType = ResourceTypeHandler.getDefaultResourceType(typeStr);
String typePath = UtilsFile.constructServerSidePath(request, resourceType);
String typeDirPath = getServletContext().getRealPath(typePath);
File typeDir = new File(typeDirPath);
UtilsFile.checkDirAndCreate(typeDir);
File currentDir = new File(typeDir, currentFolderStr);
if (!currentDir.exists())
xr = new XmlResponse(XmlResponse.EN_INVALID_FOLDER_NAME);
else {
xr = new XmlResponse(command, resourceType, currentFolderStr, UtilsResponse
.constructResponseUrl(request, resourceType, currentFolderStr, true,
ConnectorHandler.isFullUrl()));
if (command.equals(CommandHandler.GET_FOLDERS))
xr.setFolders(currentDir);
else if (command.equals(CommandHandler.GET_FOLDERS_AND_FILES))
xr.setFoldersAndFiles(currentDir);
else if (command.equals(CommandHandler.CREATE_FOLDER)) {
String tmpStr=request.getParameter("NewFolderName");
tmpStr=new String(tmpStr.getBytes("iso8859-1"),"utf-8");
String newFolderStr = UtilsFile.sanitizeFolderName(tmpStr);
logger.debug("Parameter NewFolderName: {}", newFolderStr);
File newFolder = new File(currentDir, newFolderStr);
int errorNumber = XmlResponse.EN_UKNOWN;
if (newFolder.exists())
errorNumber = XmlResponse.EN_ALREADY_EXISTS;
else {
try {
errorNumber = (newFolder.mkdir()) ? XmlResponse.EN_OK
: XmlResponse.EN_INVALID_FOLDER_NAME;
} catch (SecurityException e) {
errorNumber = XmlResponse.EN_SECURITY_ERROR;
}
}
xr.setError(errorNumber);
}
}
}
out.print(xr);
out.flush();
out.close();
logger.debug("Exiting ConnectorServlet#doGet");
}
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
logger.debug("Entering Connector#doPost");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out = response.getWriter();
String commandStr = request.getParameter("Command");
String typeStr = request.getParameter("Type");
String currentFolderStr = request.getParameter("CurrentFolder");
logger.debug("Parameter Command: {}", commandStr);
logger.debug("Parameter Type: {}", typeStr);
logger.debug("Parameter CurrentFolder: {}", currentFolderStr);
UploadResponse ur;
// if this is a QuickUpload request, 'commandStr' and 'currentFolderStr'
// are empty
if (Utils.isEmpty(commandStr) && Utils.isEmpty(currentFolderStr)) {
commandStr = "QuickUpload";
currentFolderStr = "/";
}
if (!RequestCycleHandler.isEnabledForFileUpload(request))
ur = new UploadResponse(UploadResponse.SC_SECURITY_ERROR, null, null,
Messages.NOT_AUTHORIZED_FOR_UPLOAD);
else if (!CommandHandler.isValidForPost(commandStr))
ur = new UploadResponse(UploadResponse.SC_ERROR, null, null, Messages.INVALID_COMMAND);
else if (typeStr != null && !ResourceTypeHandler.isValid(typeStr))
ur = new UploadResponse(UploadResponse.SC_ERROR, null, null, Messages.INVALID_TYPE);
else if (!UtilsFile.isValidPath(currentFolderStr))
ur = UploadResponse.UR_INVALID_CURRENT_FOLDER;
else {
ResourceTypeHandler resourceType = ResourceTypeHandler.getDefaultResourceType(typeStr);
String typePath = UtilsFile.constructServerSidePath(request, resourceType);
String typeDirPath = getServletContext().getRealPath(typePath);
File typeDir = new File(typeDirPath);
UtilsFile.checkDirAndCreate(typeDir);
File currentDir = new File(typeDir, currentFolderStr);
if (!currentDir.exists())
ur = UploadResponse.UR_INVALID_CURRENT_FOLDER;
else {
String newFilename = null;
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
//此处修改
upload.setHeaderEncoding("utf-8");
try {
List<FileItem> items = upload.parseRequest(request);
// We upload only one file at the same time
FileItem uplFile = items.get(0);
String rawName = UtilsFile.sanitizeFileName(uplFile.getName());
String filename = FilenameUtils.getName(rawName);
String baseName = FilenameUtils.removeExtension(filename);
String extension = FilenameUtils.getExtension(filename);
if (!ExtensionsHandler.isAllowed(resourceType, extension))
ur = new UploadResponse(UploadResponse.SC_INVALID_EXTENSION);
else {
// 将文件名字进行转换,换掉原先中文名字,当然可以采用日期产生文件的名字。
filename=UUID.randomUUID().toString()+"."+extension;
File pathToSave = new File(currentDir, filename);
int counter = 1;
while (pathToSave.exists()) {
newFilename = baseName.concat("(").concat(String.valueOf(counter))
.concat(")").concat(".").concat(extension);
pathToSave = new File(currentDir, newFilename);
counter++;
}
if (Utils.isEmpty(newFilename))
ur = new UploadResponse(UploadResponse.SC_OK, UtilsResponse
.constructResponseUrl(request, resourceType, currentFolderStr,
true, ConnectorHandler.isFullUrl()).concat(filename));
else
ur = new UploadResponse(UploadResponse.SC_RENAMED,
UtilsResponse.constructResponseUrl(request, resourceType,
currentFolderStr, true, ConnectorHandler.isFullUrl())
.concat(newFilename), newFilename);
// secure image check
if (resourceType.equals(ResourceTypeHandler.IMAGE)
&& ConnectorHandler.isSecureImageUploads()) {
if (UtilsFile.isImage(uplFile.getInputStream()))
uplFile.write(pathToSave);
else {
uplFile.delete();
ur = new UploadResponse(UploadResponse.SC_INVALID_EXTENSION);
}
} else
uplFile.write(pathToSave);
}
} catch (Exception e) {
ur = new UploadResponse(UploadResponse.SC_SECURITY_ERROR);
}
}
}
out.print(ur);
out.flush();
out.close();
logger.debug("Exiting Connector#doPost");
}
}
然后将web.xml中的servlet进行修改,具体修改如下:
<servlet>
<servlet-name>Connector</servlet-name>
<servlet-class>
jCuckoo.ConnectorServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Connector</servlet-name>
<url-pattern>
/fckeditor/editor/filemanager/connectors/*
</url-pattern>
</servlet-mapping>
重新部署,发布就可以实现该功能。
转载:http://blog.csdn.net/guoquanyou/article/details/3562052
发表评论
-
MAC OS 配置svn服务器
2015-07-27 16:07 736MAC如果安装了XCode,就已经自带了SVN,所以,直接使 ... -
tomcat下部署了多个项目且都使用log4j
2015-07-24 11:33 847<!--如果不定义webAppRootKey参数,那么 ... -
Eclipse里项目名有红叉,但是底下的每一个文件都没有红叉
2015-07-04 17:43 778下面每个单独的文件都没有红叉报错,整个项目上显示个红叉; ... -
maven中导入本地jar包
2015-07-03 15:57 1075要在maven中引入本地jar包,首先需要将jar包复制到项 ... -
java 执行sql脚本的3种方式 (ant,ibatis,ScriptRunner) (转)
2015-01-21 10:10 1125java执行sql文件这个问题麻烦的地方在于解析sql ... -
spring mvc 地址栏 中文传值显示乱码解决办法
2014-09-04 10:29 673修改tomcat的server.xml文件,将<Con ... -
java.sql.SQLException: Value'0000-00-00'异常解决办法及mysql的url设置(转)
2014-04-10 11:47 739一、0000-00-00错误及 ... -
hibernate配置
2014-01-07 10:19 0<prop key="hibernate.c ... -
windows下一台机器安装两个MYSQL数据库
2013-12-27 16:20 7901.正常安装第一个mysql(安装步骤省略) 2.在控制面板 ... -
服务器mysql及c3p0设置
2013-12-19 14:20 7041)interactive_timeout: 参数含义:服务器 ... -
hibernate关闭连接
2013-12-17 17:02 815通过session工厂关闭session对象。 将sessio ... -
web.xml 配置 mime-mapping
2013-12-17 15:56 14331.指定了自己的javaEncoding <servl ... -
<context-param>与<init-param>的区别与作用
2013-10-07 16:25 622web.xml的配置中<context-param> ... -
struts2和fck冲突造成无法上传图片或文件问题解决办法
2013-10-07 16:08 744struts2和fck冲突造成无法 ...
相关推荐
**JSP中的FCKeditor控件** FCKeditor是一款开源的富文本编辑器,它允许用户在网页上创建和编辑内容,类似于Word的功能,但适用于Web环境。在JSP(JavaServer Pages)中,FCKeditor常被用作网页表单的一部分,用于...
**FCKeditor控件**是Java编程中广泛使用的富文本编辑器,它的出现极大地提升了开发者在Web应用中创建和编辑内容的效率。FCKeditor以其直观的用户界面和丰富的功能,使得即便是非技术用户也能轻松地编辑出类似...
**FCKeditor Word控件** 是一款用于网页编辑的组件,尤其在JSP应用程序中广泛使用,它提供了类似Word的功能,使得用户可以在浏览器环境中进行文本编辑、格式化、插入图片等操作,极大地提升了网页交互体验。...
2. **图片和媒体管理**:用户可以直接在编辑器中上传图片,甚至嵌入视频和音频文件,支持对这些媒体资源的预览和管理。 3. **链接处理**:FCKeditor支持创建内部链接、外部链接以及电子邮件链接,还可以编辑已有的...
这涉及到表单提交、请求参数解析以及可能的文件上传(例如用户在编辑器中插入图片)。 **FCKeditor的优缺点** 优点: - 易于集成:FCKeditor提供了详细的API文档和示例,对开发者友好。 - 兼容性好:支持多种主流...
在压缩包文件中,"FCK控件"可能包含了FCKeditor的安装文件、示例代码、文档资料以及可能的第三方插件。为了使用FCKeditor,你需要解压这个文件,按照提供的文档指示进行安装和配置。通常,这包括在服务器上部署编辑...
2. **引入FCKeditor**:在JSP页面中,通过`<script>`标签引入FCKeditor的JavaScript文件。通常,你会在部分添加类似如下的代码: ```html <script type="text/javascript" src="fckeditor/fckeditor.js"> ``` 3....
在JSP页面中使用FCKeditor控件,可以极大地提升用户在网页上的文本编辑体验,因为FCKeditor是一个功能强大的开源富文本编辑器。这款编辑器支持多种编程语言集成,包括PHP、JavaScript、ASP、ASP.NET、ColdFusion、...
##### 5.6 控件允许上传的文件的类型 - 设置`FCKConfig.AllowedExtensions`来限制可上传文件类型。 ```javascript FCKConfig.AllowedExtensions = ['jpg', 'jpeg', 'gif', 'png']; ``` ##### 5.7 控制上传的...
在***项目中添加对FCKeditor的引用,可以通过直接复制DLL文件到项目的BIN目录,或者在Visual Studio工具箱中添加控件引用。此外,需要在Web.Config文件中配置相应的节点,指定编辑器的基路径和用户文件上传路径。 ...
本文将详细介绍如何在JSP中使用FCKeditor,并涵盖其基本调用方式、自定义控件使用、基本属性设置以及配置方法等内容。 #### 二、FCKeditor 的调用方式 FCKeditor 在JSP中的调用主要分为两种方式: ##### 方法一:...
常见的JSP文本编辑器控件有CKEditor、TinyMCE、FCKeditor等。它们都是开源项目,提供了丰富的API和插件,可以根据实际需求进行定制。例如,CKEditor支持多种语言,有良好的可扩展性;TinyMCE轻量级且性能优秀,适用...
此外,还可以通过服务器端的配置来指定上传文件的路径、大小限制以及文件类型检查。 然而,在GBK编码环境下,由于FCKEditor默认使用UTF-8编码,可能会导致输入或显示中文时出现乱码。为了解决这个问题,我们需要对...
1. **控件集成**:在ASP.NET中,FCKeditor可以通过控件的形式轻松嵌入到网页中。开发者只需在页面上添加控件,并设置相应的属性,就可以在服务器端获取到编辑后的文本。 2. **服务器端交互**:ASP.NET与FCKeditor的...
1. 概述 对于大多数用户来说,将Word中的图片上传到Web服务器来说是一件非常不方便的事情,许多...当控件升级(版本号修改)或CAB文件位置改变,必须修改ImagePaster.js中的代码。否则用户的IE浏览器将无法正常加载控件。
- FCKeditor是一个JavaScript库,通过在网页中嵌入编辑器控件,使得用户能够在浏览器中创建、编辑和格式化文本。 - 其主要功能包括:字体样式调整、段落格式设置、插入图片、超链接、表格操作、多媒体内容插入等。...
在Struts2中配置FCKeditor,首先需要在项目的类路径下添加FCKeditor的库文件,包括JavaScript文件和相关的CSS样式表。这些文件通常可以从FCKeditor的官方网站下载得到,包含fckeditor.js、fckconfig.js等核心文件。 ...
在.NET环境中,FCKeditor通常作为服务器控件使用,与ASP.NET结合,提供用户友好的内容编辑体验。开发人员可以通过简单的配置和脚本调用来集成编辑器,使其能够接收和显示用户输入的富文本内容。FCKeditor的.NET版本...