<!-- 富文本编译器 --> <script type="text/javascript" src="static/editor/kindeditor-all-min.js"></script> <script type="text/javascript" src="static/editor/lang/zh-CN.js"></script> <script> editor.sync(); </script> <textarea name="articles_content" id="articles_content" style="80%;height:500px;"></textarea> <script type="text/javascript"> //富文本编译器 KindEditor.ready(function(K) { window.editor = K.create('#articles_content',{ items:[ 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak', 'anchor', 'link', 'unlink' ], uploadJson : '<%=basePath%>articles/saveArticlesPic', allowFileManager : true }); }) </script>
@RequestMapping(value="/saveArticlesPic", method = RequestMethod.POST) @ResponseBody public Object saveArticlesPic(@RequestParam(required = false) MultipartFile imgFile,HttpSession session) throws Exception { String get32uuid = this.get32UUID(); Map<String,Object> map = new HashMap<String,Object>(); if (null != imgFile && !imgFile.isEmpty()) { //上传到本地准备切图 String ffile = System.currentTimeMillis()+""; String lFilePath = PathUtil.getClasspath() + Const.FILEPATHIMG +"goods/xc/articles/"+ ffile ; // 文件上传路径 Map<String, String> cutfileUp = FileUpload.cutfileUp(get32uuid, imgFile, lFilePath); //上传到ftp服务器 String fileName = cutfileUp.get("fileName"); String filePath = "/static/public/goods/xc/articles"; // 文件上传路径 String ytPath = PathUtil.getClasspath() + Const.FILEPATHIMG +"goods/xc/articles"; Map<String, String> imgUrls = new FileUpload().goodsPICFileUp(cutfileUp,lFilePath ,filePath,ytPath); // 执行上传 ImageImage image = new ImageImage(); get32uuid = this.get32UUID(); image.setImage_id(get32uuid); image.setImage_name(fileName); image.setUrl(imgUrls.get("org")); image.setL_url(imgUrls.get("b")); image.setM_url(imgUrls.get("m")); image.setS_url(imgUrls.get("s")); image.setLast_modified(System.currentTimeMillis()/1000+""); //ftpPath = imgUrls.get("org"); String bizuntcd = (String) session.getAttribute(Const.BIZUNTCD); image.setBizuntcd(bizuntcd); map.put("error", 0); map.put("url", imgUrls.get("org")); } else { System.out.println("上传失败"); } return AppUtil.returnObject(new PageData(), map); }