前台代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<script type="text/javascript" src="Dropzone/dropzone.min.js"></script>
<link rel="stylesheet" type="text/css" href="Dropzone/css/basic.css"><link>
<link rel="stylesheet" type="text/css" href="Dropzone/css/dropzone.css"><link> <script> Dropzone.options.dropzoneForm = {
//添加上传取消和删除预览图片的链接,默认不添加
addRemoveLinks: true,
init : function() {
this.on("success", function(file, res){});
//删除图片的事件,当上传的图片为空时,使上传按钮不可用状态
this.on("removedfile", function () {
if (this.getAcceptedFiles().length === 0) {
$("#dropzoneForm").attr("disabled", true);
}
});
}
}; </script> <body> <form action="<%= request.getContextPath()%>/vehicleBasic/upload.do" method="post" enctype="multipart/form-data" class="dropzone" id="dropzoneForm">
</form> </body>
</html>

后台代码:

    @RequestMapping("upload")
@ResponseBody
public String upload(@RequestParam(value = "file", required = false) MultipartFile file,
HttpServletRequest request, HttpServletResponse response) throws IOException{
response.setHeader("Access-Control-Allow-Origin","*");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSS");
String res = sdf.format(new Date());
// uploads文件夹位置
//String rootPath = request.getSession().getServletContext().getRealPath("vehFile");
String rootPath = "ehFile/";
// 原始名称
String originalFileName = file.getOriginalFilename();
// 新文件名
String newFileName = res + originalFileName.substring(originalFileName.lastIndexOf("."));
// 新文件
File newFile = new File(rootPath +File.separator + newFileName);
// 判断目标文件所在目录是否存在
if( !newFile.getParentFile().exists()) {
// 如果目标文件所在的目录不存在,则创建父目录
newFile.getParentFile().mkdirs();
}
System.out.println(newFile);
System.out.println(originalFileName);
// 将内存中的数据写入磁盘
file.transferTo(newFile);
// 完整的url
String fileUrl =rootPath + newFileName;
return fileUrl;
}

DropZone资源路径:

http://download.csdn.net/download/s0009527/10198590

DropZone图片上传控件的使用的更多相关文章

  1. 百度Ueditor多图片上传控件

    发现百度的Ueditor富文本编辑器中的多图片上传控件很不错,于是便想着分享出来使用,费了老劲,少不了无名朋友的帮助,也查了不少资料,终于搞定了 发代码给大家,请大家多多指正 1.首先要在html页面 ...

  2. java+Word图片上传控件

    这种方法是servlet,编写好在web.xml里配置servlet-class和servlet-mapping即可使用 后台(服务端)java服务代码:(上传至ROOT/lqxcPics文件夹下) ...

  3. uedit富文本编辑器及图片上传控件

    微力后台 uedit富文本编辑器及文件上传控件的使用,无时间整理,暂略,参考本地代码.能跑起来.

  4. Word图片上传控件(WordPaster)更新-2.0.15版本

    更新说明: 1.   增加对webp图片的支持,支持微信公众号图片的下载. 效果参考:http://www.ncmem.com/doc/view.aspx?id=9761f8ce4fe04d0ab0f ...

  5. WebUploader 图片上传控件使用范例

    ​官网 http://fex.baidu.com/webuploader/getting-started.html 其实官网写的挺详细的,看官网也可以了. 引入资源 使用Web Uploader文件上 ...

  6. bootstrap图片上传控件 fileinput

    前端 1.要引用的js fileinput.js      fileinput.css <link type="text/css" rel="stylesheet& ...

  7. 基于jQuery仿uploadify的HTML5图片上传控件jquery.html5uploader

    (function($){ var methods = { init:function(options){ return this.each(function(){ var $this = $(thi ...

  8. Word图片上传控件卸载教程-Xproer.WordPaster

      卸载教程:      卸载控件-IE          Windows XP          Windows 7(x86)          Windows 7(x64)      卸载控件-C ...

  9. Word图片上传控件-eWebEditor9x整合教程-Xproer.WordPaster

    示例下载(JSP):eWebEditor9x, 示例下载(.NET):eWebEditor9x,   1.1. 集成到eWebEditor9x 主要步骤如下: 1.增加WordPaster文件夹   ...

随机推荐

  1. MySQL 5.7远程连接

    将/etc/mysql/my.cnf中的bind_address那一行注释掉或修改为"bind_address=0.0.0.0": bind_address并没有在/etc/mys ...

  2. 2753: [SCOI2012]滑雪与时间胶囊

    2753: [SCOI2012]滑雪与时间胶囊 Time Limit: 50 Sec  Memory Limit: 128 MBSubmit: 2633  Solved: 910 Descriptio ...

  3. android stadio mapping文件的使用

    mapping文件就是在对代码混淆以后,你用来查看混淆前和混淆后的对比文件. 一般用来查看线上的bug; java.lang.NullPointerException: Attempt to invo ...

  4. Javacript实现倒计时

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  5. 后端接口迁移(从 webapi 到 openapi)前端经验总结

    此文已由作者张磊授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 前情提要 以前用的是 webapi 现在统一切成 openapi,字段结构统统都变了 接入接口 20+,涉及模 ...

  6. 斐波那契数列(Fibonacci) iOS

    斐波那契数列Fibonacci 斐波那契数列指的是这样一个数列 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,377,610,987,1597,2 ...

  7. Kinect关于PlayerIndex和SkeletonId之间的关系。

    项目中要锁定玩家骨骼后抠图, 一时没有灵感.google 关键词: the ralationship about skeletonid and playerindex. 结论: Player Segm ...

  8. 【APUE】Chapter7 Process Environment

    这一章内容是Process的基础准备篇章.这一章的内容都是基于C Programm为例子. (一)进程开始: kernel → C start-up rountine → main function ...

  9. 用JAX-WS在Tomcat中发布WebService

    JDK中已经内置了Webservice发布,不过要用Tomcat等Web服务器发布WebService,还需要用第三方Webservice框架.Axis2和CXF是目前最流行的Webservice框架 ...

  10. Kotlin中的“忍者”函数 —— 理解泛型的能力(KAD 12)

    作者:Antonio Leiva 时间:Feb 8, 2017 原文链接:https://antonioleiva.com/generic-functions-kotlin/ Kotlin的一些特性组 ...