引入插件:
/* * 上传文件配置 * */ //配置uploader var uploader = new plupload.Uploader({ runtimes: 'html5,flash,silverlight,html4', browse_button : 'uploader', url:'/delivery/batchSendByFile', flash_swf_url : '../Moxie.swf', silverlight_xap_url : '../Moxie.xap', multi_selection:false, filters: { mime_types : [ //只允许上传xls和xlsx文件 { title : "xls files", extensions : "xls" }, { title : "xlsx files", extensions : "xlsx" } ] }, preinit: { UploadFile: function (up) { up.setOption('url', '/delivery/batchSendByFile'); } } }); uploader.bind('Error', function (uploader, errObject) { var message = ''; //解除锁定 layer.closeAll('loading'); if (errObject.code === -600) { message = '上传的文件太大'; } else if (errObject.code === -200) { message = '由于网络原因,文件没有上传成功'; } else if (errObject.code === -601) { message = '选择的文件类型不是xls或xlsx类型'; } layer.msg('上传失败,错误原因:' + message,{end:function(){ layer.closeAll(); }}); }); //选中文件触发 uploader.bind('FilesAdded', function(uploader,files) { var tipElement = $('#uploadBox').find('.J_side'); controller.uploadFlag = true; for(var i = 0, len = files.length; i