码迷,mamicode.com
首页 > 编程语言 > 详细

Plupload+easyui+springmvc实现批量上传

时间:2015-06-11 20:57:57      阅读:863      评论:0      收藏:0      [点我收藏+]

标签:

1.jsp代码

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<link rel="stylesheet" href="${ctx}/static/js/plupload/queue/css/jquery.plupload.queue.css" type="text/css"></link>
<script type="text/javascript" src="${ctx}/static/js/plupload/plupload.js"></script>
<script type="text/javascript" src="${ctx}/static/js/plupload/plupload.html4.js"></script>
<script type="text/javascript" src="${ctx}/static/js/plupload/plupload.html5.js"></script>
<script type="text/javascript" src="${ctx}/static/js/plupload/plupload.flash.js"></script>
<script type="text/javascript" src="${ctx}/static/js/plupload/zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/static/js/plupload/queue/jquery.plupload.queue.js"></script>
<script type="text/javascript">
    var ctx=‘${ctx}‘+‘static/js/‘;
    var files = [];
    var errors = [];
    var type = ‘file‘;
    var max_file_size = ‘10mb‘;
    $(document).ready(function(){
        var filters = {title : "文档", extensions : "xml"};
        $("#uploader").pluploadQueue($.extend({
            runtimes : ‘html5,html4,flash‘,
            url : ‘localUpLoadProgram‘,
            max_file_size : max_file_size,
            file_data_name:‘file‘,
            unique_names:true,
            filters : [filters],
            flash_swf_url : ctx+‘plupload/plupload.flash.swf‘,
            init:{
                FileUploaded:function(uploader,file,response){
                    if(response.response){
                        var rs = $.parseJSON(response.response);
                        if(rs.status){
                            files.push(file.name);
                        }else{
                            errors.push(file.name);
                        }
                    }
                },
                UploadComplete:function(uploader,fs){
                    //var e= errors.length ? ",失败"+errors.length+"个("+errors.join("、")+")。" : "。";
                   // alert("上传完成!共"+fs.length+"个。成功"+files.length+e);
                    //target.window("close");
                }
            }
        },(true ? {chunk_size:‘1mb‘} : {})));
    });
</script>
<div id="uploader">&nbsp;</div>

 

2.java代码
    @RequestMapping("/standsUpLoadProgram")
    @ResponseBody
    public void standsUpLoadProgram(
            @RequestParam("file") CommonsMultipartFile[] file,
            HttpServletResponse response) throws Exception {
        if (file.length <= 0) {
            return;
        }
        for (int i = 0; i < file.length; i++) {
            InputStream inputFile = file[i].getInputStream();
            saveStandsDate(inputFile);
        }
    }

 

Plupload+easyui+springmvc实现批量上传

标签:

原文地址:http://www.cnblogs.com/holdon521/p/4570004.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!