上传代码整理
来源:互联网 发布:周易生辰八字取名软件 编辑:程序博客网 时间:2024/06/02 04:31
new.js
$(function(){prepareUpload("",1);//提交表单$("#submitBtn").click(function(){if($("#dataForm").valid()){if($("#fileQueue").text()!=''){var date=new Date();var fold=date.format("yyyyMMddhhmmss");$("#uploadify").uploadify("settings","formData",{'fold':fold});$('#uploadify').uploadify('upload','*');}else{//setVMessage("请选择要上传的课件!");alert("请选择要上传的课件!");}}});});Date.prototype.format = function(format){ var o = { "M+" : this.getMonth()+1, //month "d+" : this.getDate(), //day "h+" : this.getHours(), //hour "m+" : this.getMinutes(), //minute "s+" : this.getSeconds(), //second "q+" : Math.floor((this.getMonth()+3)/3), //quarter "S" : this.getMilliseconds() //millisecond }if(/(y+)/.test(format)) { format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); } for(var k in o) { if(new RegExp("("+ k +")").test(format)) { format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); } } return format; } /* * 上传插件的方法重载 * * start */function onSelect(file){var fileName=file.name;fileName=fileName.substring(0,fileName.lastIndexOf("."));$("#name").val(fileName);}function onUploadSuccess(){$("#dirPath").val(adjunctPath);if(canSubmit){document.dataForm.submit();}}
<script src="<c:url value='/resources/js/upload/jquery.uploadify-3.1.min.js' />"></script><script src="<c:url value='/resources/js/upload.js' />"></script><script src="<c:url value="/resources/js/courseware/new.js" />" type="text/javascript"></script><style type="text/css"> .uploadify-button { background-color: transparent; border: none; padding: 0; } .uploadify:hover .uploadify-button { background-color: transparent; } </style><tr><th>选择课件:</th><td><input type="file" name="uploadify" id="uploadify" /><em>*只支持单个文件上传,如果有多个文件请打包成zip格式</em><div id="fileQueue"></div></td></tr>
@RequestMapping(value = "/upload", method = RequestMethod.POST, produces = "text/html;charset=UTF-8") @ResponseBody public String upload(MultipartFile Filedata, HttpServletRequest request, String fold) throws IOException { String fileName = Filedata.getOriginalFilename(); String preffix=fileName.substring(0,fileName.lastIndexOf(".")); preffix=CommonUtils.getMD5(preffix); String suffix = fileName.substring(fileName.lastIndexOf(".")); fileName=preffix+suffix; String path = realRootPath+ fold+"_"+preffix; path += File.separator + fileName; FileUtils.copyInputStreamToFile(Filedata.getInputStream(), new File(path)); path = path.replaceAll("\\\\", "/"); return path; }
所需的js等等都在资源处:
0 0
- 上传代码整理
- IOS上传照片(自己的代码整理了一下)
- IOS上传照片(自己的代码整理了一下)
- Github上传代码 整理(14/6/11晚搞定)
- IOS上传照片(自己的代码整理了一下)
- 阿里云OSS 分块上传的代码整理
- Android 将代码整理后重新上传svn的不同地址进行代码管理
- 代码整理
- 代码整理
- .net文件上传(整理)
- 文件上传知识整理
- FTP 文件上传整理
- flex 上传整理
- uploadify文件上传整理
- yii2上传整理
- 文件上传知识点整理
- 【git】创建一个新的本地仓库并上传代码(整理)
- 上传简历的上传代码
- cer, pfx 创建,并且读取公钥/密钥,加解密 (C#程序实现)
- Spring常用注解
- C++中的输入问题
- 【Axure教程】如何更好的用Axure写产品需求文档
- Asp.Net alert弹出提示信息的5种方法
- 上传代码整理
- ffmpeg 调试
- 关于在Android上检测是否存在网络的问题
- sql 提取不重复记录
- 2014-10-10 约瑟夫环+循环列表
- Linux操作系统的安装
- NSMutableString 替换字符串的时候option选择解释
- 回掉函数与函数指针
- 第七周项目三计算圆柱体的表面积