- //D:\Tomcat6.0\webapps\zswz\attached/
- String savePath = request.getSession().getServletContext().getRealPath("/").replace("hzview","red5") + "streams/";
- //文件保存目录URL /zswz/attached/
- String saveUrl = "/red5/"+ "streams/";
- System.out.println(savePath);
- System.out.println(saveUrl);
- //定义允许上传的文件扩展名
- //定义允许上传的文件扩展名
- HashMap<String, String> extMap = new HashMap<String, String>();
- extMap.put("p_w_picpath", "gif,jpg,jpeg,png,bmp");
- extMap.put("flash", "swf,flv,mp4");
- extMap.put("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb,mp4");
- extMap.put("file", "doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2");
- if (!Arrays.<String> asList(extMapif.get(dirName).split(","))
- .contains(fileExt2)) {
- HashMap<String, String> extMap2 = new HashMap<String, String>();
- extMap2.put("flash", "swf,flv");
- extMap2.put("media",
- "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb,mp4");
- if (Arrays.<String> asList(extMap2.get(dirName).split(","))
- .contains(fileExt2)) {
- String filePath = savePath + newImgName;
- String filePath2 = savePath;
- ConverVideo cv = new ConverVideo(filePath, filePath2,
- filePath2, filePath2, filePath2);
- // ConverVideo cv=new ConverVideo(filePath);
- cv.beginConver();
- //ProcessFlvImg pfi = new ProcessFlvImg();
- // pfi.processImg(filePath);
- }
- }
- <link rel="stylesheet" href="<%=path %>/kindeditor/themes/default/default.css" />
- <link rel="stylesheet" href="<%=path %>/kindeditor/plugins/code/prettify.css" />
- <script charset="utf-8" src="<%=path %>/kindeditor/kindeditor.js"></script>
- <script charset="utf-8" src="<%=path %>/kindeditor/lang/zh_CN.js"></script>
- <script charset="utf-8" src="<%=path %>/kindeditor/plugins/code/prettify.js"></script>
- <script>
- KindEditor.ready(function(K) {
- var editor1 = K.create('textarea[name="content"]', {
- afterUpload :function (url) {
- // alert(url);
- var _msg = url.toString();
- var _picture_name = _msg.substring(_msg
- .lastIndexOf("/") + 1);
- var _picture_path = Substring(_msg);
- var _p_w_picpathstr = "<input type='checkbox' name='p_w_picpathUrl' checked='checked' value='"+url+"' id='"+url+"' onClick='clickImage(this.value);this.checked=false ' />附件<label>"+_picture_name+"</label></a><br/>";
- var p_w_picpathArray = new Array(".jpg", ".jpeg", ".gif",
- ".png", ".bmp");
- var hou = _msg.substring(_msg.lastIndexOf("."));
- for ( var i = 0; i < p_w_picpathArray.length; i++) {
- if (p_w_picpathArray[i] == hou) {
- $("#uploadList").append(_p_w_picpathstr);
- }
- }
- var _videostr = "<input type='checkbox' name='videoUrl' checked='checked' value='"+ url+ "' id='"+url+"' onClick='clickImage(this.value);this.checked=false' />附件<label>"
- + _picture_name
- + "</label></a><br/>";
- var videoArray = new Array(".swf", ".flv", ".avi",
- ".mp3", ".wav",".wma",".wmv",".mid",".mpg",".asf",".rm",".rmvb",".mp4");
- for ( var i = 0; i < videoArray.length; i++) {
- if (videoArray[i] == hou) {
- $("#videouploadList").append(_videostr);
- }
- }
- },
- cssPath : '<%=path %>/kindeditor/plugins/code/prettify.css',
- uploadJson : '<%=path %>/kindeditor/jsp/upload_json.jsp',
- fileManagerJson : '<%=path %>/kindeditor/jsp/file_manager_json.jsp',
- allowFileManager : true,
- filterMode:false,
- afterCreate : function() {
- var self = this;
- K.ctrl(document, 13, function() {
- self.sync();
- document.forms['example'].submit();
- });
- K.ctrl(self.edit.doc, 13, function() {
- self.sync();
- document.forms['example'].submit();
- });
- }
- });
- prettyPrint();
- });
- function Substring(s) {
- return s.substring(s.substring(0,
- s.lastIndexOf("/")).lastIndexOf("/"),
- s.length);
- }
- function clickImage(abc)
- {
- alert(abc);
- var r = confirm("你确认要删除吗?");
- // if(document.abc.checked){
- // abc.style.display="none"
- // }
- if (r == true) {
- $("#"+abc).attr("display","none");
- var url = 'deletefile';
- var params = {
- p_w_picpathUrl : abc
- };
- jQuery.post(url, params, callbackFun, 'json');
- return true;
- }
- }
- // style="display:none"
- function callbackFun(data)
- {
- alert(data.result);
- return true;
- //对应HelloWorld类的message属性
- //获取数据后渲染页面
- }
- <td>
- 上传文件必须在 ?之间
- <br>
- <textarea name="content" cols="100" rows="8" style="width:700px;height:200px;visibility:hidden;"></textarea>
- </td>
- <hr />
- <tr>
- <td>
- 图片URL:
- </td>
- <td>
- <div id="uploadList"></div>
- </td>
- </tr>
- <br>
- <tr>
- <td>
- 视频音频URL:
- </td>
- <td>
- <div id="videouploadList"></div>
- <br>
- </td>
- </tr>
转载于:https://blog.51cto.com/joint4/1059121