1.在jsp中引入css与js文件,

  <link href="${ctx}/plugins/fileup/css/fileinput.css" media="all" rel="stylesheet" type="text/css"/>----css
  <script type="text/javascript" src="${ctx}/plugins/fileup/js/fileinput.js"/>----js
  <script src="${ctx}/plugins/fileup/js/fileinput_locale_th.js" type="text/javascript"></script>----
  <script src="${ctx}/plugins/fileup/js/fileinput_locale_zh.js" type="text/javascript"></script>----字体

2.在jsp中初始化文件上传控件:

$(document).ready(function(){
/* 输入框联想 */
new CommunitySelect('searchCommunityName','${ctx}');
$('#table').bootstrapTable({
method:'post'
});

$("#edit").on("hidden.bs.modal", function(){
$(this).removeData("bs.modal");
});
//文件上传
$('#file-zh').fileinput({
language: 'zh',
maxFilesNum: 1,
maxFileSize: 5000,
uploadUrl: '${ctx}/mindex/importCityIndex.do', //请求的路径

showUpload: true,

showRemove: true,
uploadAsync: true,
showPreview : true,
showCancel : false,
allowedFileExtensions: ['xlsx', 'xls']    //限定文件的类型
});
});

$("#file-zh").on("fileuploaded", function(event, data, previewId, index) {
var result = data.response;
if (result.success) {
$("#uploadModal").modal("hide");
$('#table').bootstrapTable("refresh");
bootbox.alert(result.msg);
} else {
bootbox.alert(result.msg);
}
});

3.在jsp中主体部分添加弹出窗体

//上传的按钮

<a href="#uploadModal" class="btn bg-blue" data-toggle="modal" data-preview-file-type="lsx/xlsx"><i
class="fa fa-download"></i> 上传</a>

<div class="modal fade" id="uploadModal" tabindex="-1" role="basic" aria-hidden="true">

    <form enctype="multipart/form-data" id="uploadForm" method="post">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true"></button>
<h4 class="modal-title">导入</h4> <div class="modal-body">
<div class="form-group">
<input id="file-zh" name="xlsFile" type="file" multiple>
</div>
</div>
</div>
</div>
</div>
</form>
</div> 4、在controller中添加handler
@RequestMapping("importCityIndex")
@ResponseBody
public AjaxJson importCommunity(@RequestParam("xlsFile") MultipartFile file) throws IOException{
  //file 得到要上传文件的输入流对象
  
InputStream inputStream = file.getInputStream();
}

Bootstrap Fileupload 文件上传的更多相关文章

  1. 对FileUpload文件上传控件的一些使用方法说明

    //创建时间:2014-03-12 //创建人:幽林孤狼 //说明:FileUpload文件上传控件使用说明(只是部分)已共享学习为主 //可以上传图片,txt文档.doc,wps,还有音频文件,视屏 ...

  2. SpringBoot+BootStrap多文件上传到本地

    1.application.yml文件配置 # 文件大小 MB必须大写 # maxFileSize 是单个文件大小 # maxRequestSize是设置总上传的数据大小 spring: servle ...

  3. bootstrap fileinput 文件上传

    最近因为项目需要研究了下bootstrap fileinput的使用,来记录下这几天的使用心得吧. 前台html页面的代码 <form role="form" id=&quo ...

  4. FileUpload文件上传控件

    1.FileUpload控件的主要功能是向指定目录上传文件.FileUpload控件不会自动上传控件,而需要设置相关的事件处理程序,然后在程序中实现文件上传. 2.FileUpload控件常见的属性 ...

  5. ASP.NET中的FileUpload文件上传控件的使用

    本篇文章教大家如何将客户端的图片或者文件上传到服务器: 无论是上传图片(.jpg .png .gif等等) 文档(word excel ppt 等等). 第一步:放入以下三个控件 Image控件,Fi ...

  6. apache fileupload 文件上传,及文件进度设置获取

    文件上传action处理: boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (isMultipart) ...

  7. Commons FileUpload文件上传组件

    Java实现的文件上传组件有好几种,其中最为“官方”的要数Apache Commons库中的FileUpload了吧. 页面 <form method="POST" enct ...

  8. bootstrap fileinput 文件上传工具

    这是我上传的第二个plugin 首先第一点就是因为这个好看 符合bootstrap的界面风格 第二是可以拖拽(虽然我不常用这个功能 但是这样界面看起来就丰满了很多) 最后不得不吐槽这个的回发事件 我百 ...

  9. commons.fileupload 文件上传

    编辑jsp页面获取文件 <html> <head> <base href="<%=basePath%>"> <title> ...

随机推荐

  1. 第一个Android应用--签证无忧 上线

    用了大概1个多星期的时间,把一个简单的应用完成,[签证无忧]是基于在我所在公司办理签证的前提下,为方便客户查询进度所开发,后来我加了淘宝的购买链接,这样客人在以后需要时不需要到淘宝查找了. 签证无忧这 ...

  2. smarty下如何将一个数保存为两位小数

    smarty模板是一种缓存技术,下面介绍一下smarty string_format用法 取小数点后2位: 用法如下: //index.php$smarty = new Smarty; $smarty ...

  3. Sunny-ngrok 解决外网访问内网问题

       该博文已过时    请参考官网        http://www.ngrok.cc/ 一  .进入 网址 往下拉找到: 下载不同的版本. 二. 平台登陆地址:http://www.ngrok. ...

  4. 通过form上传文件(php)

    前段代码 <html> <head> <meta http-equiv="Content-Type" content="text/html; ...

  5. python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?

    python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...

  6. Leetcode 144. Binary Tree Preorder Traversal

    参考例子:[8,3,1,6,4,7,10,14,13] 8,3,1 和 6,4 说明从root开始,沿着左臂向下寻找leaf 的过程中应该逐个将node.val push入ans. class Sol ...

  7. windows下MySQL 忘记初始密码

    一.windows下修改MySQL用户密码的方法:   1.关闭正在运行的MySQL服务:net stop mysql  或 在windows 任务管理器中结束 mysqld.exe 进程 或 在 管 ...

  8. bzoj2064[和谐社会模拟赛]分裂

    题意:给定一个初始集合和目标集合,有两种操作:1.合并集合中的两个元素,新元素为两个元素之和 2.分裂集合中的一个元素,得到的两个新元素之和等于原先的元素.要求用最小步数使初始集合变为目标集合,求最小 ...

  9. python中文分词:结巴分词

    中文分词是中文文本处理的一个基础性工作,结巴分词利用进行中文分词.其基本实现原理有三点: 基于Trie树结构实现高效的词图扫描,生成句子中汉字所有可能成词情况所构成的有向无环图(DAG) 采用了动态规 ...

  10. Linux系统概述

    1.Linux是一套免费使用 和自 由传播的类Unix操作系统. 这个系统是由世界各地的成千上万的程序员 设计和实现的.其目 的是建立不受任何商品化软件的版权制约的. 全世界都能自 由使用的Unix兼 ...