{"action":"reopened","issue":{"url":"https://api.github.com/repos/wangfupeng1988/wangEditor/issues/985","repository_url":"https://api.github.com/repos/wangfupeng1988/wangEditor","labels_url":"https://api.github.com/repos/wangfupeng1988/wangEditor/issues/985/labels{/name}","comments_url":"https://api.github.com/repos/wangfupeng1988/wangEditor/issues/985/comments","events_url":"https://api.github.com/repos/wangfupeng1988/wangEditor/issues/985/events","html_url":"https://github.com/wangfupeng1988/wangEditor/issues/985","id":255508987,"number":985,"title":"关于图片上传，后台接收不到参数的问题。 wangEditor上传后如何接收参数？文档上没说明白，谢谢解答","user":{"login":"EthanDCX","id":18240991,"avatar_url":"https://avatars0.githubusercontent.com/u/18240991?v=4","gravatar_id":"","url":"https://api.github.com/users/EthanDCX","html_url":"https://github.com/EthanDCX","followers_url":"https://api.github.com/users/EthanDCX/followers","following_url":"https://api.github.com/users/EthanDCX/following{/other_user}","gists_url":"https://api.github.com/users/EthanDCX/gists{/gist_id}","starred_url":"https://api.github.com/users/EthanDCX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EthanDCX/subscriptions","organizations_url":"https://api.github.com/users/EthanDCX/orgs","repos_url":"https://api.github.com/users/EthanDCX/repos","events_url":"https://api.github.com/users/EthanDCX/events{/privacy}","received_events_url":"https://api.github.com/users/EthanDCX/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-09-06T07:38:17Z","updated_at":"2017-09-11T07:08:22Z","closed_at":null,"author_association":"NONE","body":"```javascript\r\n <script type=\"text/javascript\">\r\n            var E = window.wangEditor\r\n            var editor = new E('#editor')\r\n            editor.customConfig.menus = [\r\n                'bold',\r\n                'italic',\r\n                'foreColor',  // 文字颜色\r\n                'link',  // 插入链接\r\n                'list',  // 列表\r\n                'underline',\r\n                \"image\",\r\n                \"table\",\r\n                \"vidio\",\r\n                \"undo\",\r\n            ]\r\n            // 或者 var editor = new E( document.getElementById('#editor') )\r\n            editor.customConfig.uploadImgServer = '<%=basePath%>/upload/uploadImg.do'\r\n            editor.customConfig.showLinkImg = false\r\n            editor.customConfig.uploadImgMaxSize = 3 * 1024 * 1024\r\n            editor.customConfig.uploadImgMaxLength = 5\r\n            document.getElementById('btn1').addEventListener('click', function() {\r\n                // 读取 html 要把editor.txt.html传到后台\r\n                alert(editor.txt.html())\r\n                document.all.answer.value = editor.txt.html();//给name为answer的隐藏域赋值\r\n            }, false)\r\n            editor.create()\r\n        \r\n        </script>\r\n```javascript\r\n\r\n后台：\r\n```java\r\n  public String upload( List<MultipartFile> tmpFiles, HttpServletRequest request) {\r\n        int fileSize = tmpFiles.size();\r\n        String answerId = request.getParameter(\"answerId\");\r\n        //拿到多张图片，要遍历保存每张图片\r\n        if(fileSize>0){\r\n            String totleImg=\"\";\r\n        for (MultipartFile tmpFile :tmpFiles) {\r\n//             获取物理路径\r\n                String targetDirectory = request.getSession().getServletContext().getRealPath(\"/uploads\");\r\n                String tmpFileName = tmpFile.getOriginalFilename(); // 上传的文件名\r\n                int dot = tmpFileName.lastIndexOf('.');\r\n                String ext = \"\";  //文件后缀名\r\n                if ((dot > -1) && (dot < (tmpFileName.length() - 1))) {\r\n                    ext = tmpFileName.substring(dot + 1);\r\n                }\r\n                // 其他文件格式不处理\r\n                if (\"png\".equalsIgnoreCase(ext) || \"jpg\".equalsIgnoreCase(ext) || \"gif\".equalsIgnoreCase(ext) || \"jpeg\".equalsIgnoreCase(ext)) {\r\n                    // 重命名上传的文件名\r\n                    String targetFileName = renameFileName(tmpFileName);\r\n                    // 保存的新文件\r\n                    File target = new File(targetDirectory, targetFileName);\r\n                    //拿到img的相对路径，传入model就ok  要把相对路径根据answer id，放到qa表里\r\n                    String imgPath = \"/uploads/\" + targetFileName;\r\n                    totleImg = totleImg+ \",\"+imgPath;\r\n                    int i = iqaService.updatePictureUrl(imgPath, Integer.valueOf(answerId),fileSize,totleImg); //更新成功返回1\r\n                    //提示上传成功\r\n                    try {\r\n                        // 保存文件\r\n                        FileUtils.copyInputStreamToFile(tmpFile.getInputStream(), target);\r\n                    } catch (IOException e) {\r\n                        e.printStackTrace();\r\n                    }\r\n                }\r\n            }\r\n            //TODO 把totleImg转成json格式，返回给前台\r\n            String[] imgPath = totleImg.substring(1).split(\",\");\r\n            Gson gson = new Gson();\r\n            String json = gson.toJson(imgPath);\r\n            String result=\"{error:0,data:'+json+'}\";\r\n            return result;\r\n        }\r\n\r\n        return \"fail\";\r\n    }\r\n```java"}}
{"actor":{"display_login":"wangfupeng1988"}}