ckeditor/plugins/image/dialogs/image.js
ckeditor/plugins/image/dialogs/image.js
**/
public String uploadFile(){
//获得客户端会调的函数
String callback=ServletActionContext.getRequest().getParameter("CKEditorFuncNum");
try{
String ext=uploadFileName.substring(uploadFileName.lastIndexOf("."));
String newName=UUID.randomUUID().toString().replace("-","")+ext;
//获得服务器上目录的绝对路径
String path=ServletActionContext.getServletContext().getRealPath("/upload");
//创建File对象
File file=new File(path,newName);
//将上传的文件保存到服务器的目录下
FileUtils.copyFile(upload,file);
String uri="upload/"+newName;
StringBuffer sb=new StringBuffer();
sb.append("<script type=\"text/javascript\">");
sb.append("window.parent.CKEDITOR.tools.callFunction("+callback+",‘"+uri+"‘,‘‘);");
sb.append("</script>");
//this.inputStream=new ByteArrayInputStream(sb.toString().getBytes());
ServletActionContext.getResponse().getWriter().write(sb.toString());
原文地址:http://blog.51cto.com/13654477/2088288