Bootstrap Fileupload 文件上传
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 文件上传的更多相关文章
- 对FileUpload文件上传控件的一些使用方法说明
//创建时间:2014-03-12 //创建人:幽林孤狼 //说明:FileUpload文件上传控件使用说明(只是部分)已共享学习为主 //可以上传图片,txt文档.doc,wps,还有音频文件,视屏 ...
- SpringBoot+BootStrap多文件上传到本地
1.application.yml文件配置 # 文件大小 MB必须大写 # maxFileSize 是单个文件大小 # maxRequestSize是设置总上传的数据大小 spring: servle ...
- bootstrap fileinput 文件上传
最近因为项目需要研究了下bootstrap fileinput的使用,来记录下这几天的使用心得吧. 前台html页面的代码 <form role="form" id=&quo ...
- FileUpload文件上传控件
1.FileUpload控件的主要功能是向指定目录上传文件.FileUpload控件不会自动上传控件,而需要设置相关的事件处理程序,然后在程序中实现文件上传. 2.FileUpload控件常见的属性 ...
- ASP.NET中的FileUpload文件上传控件的使用
本篇文章教大家如何将客户端的图片或者文件上传到服务器: 无论是上传图片(.jpg .png .gif等等) 文档(word excel ppt 等等). 第一步:放入以下三个控件 Image控件,Fi ...
- apache fileupload 文件上传,及文件进度设置获取
文件上传action处理: boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (isMultipart) ...
- Commons FileUpload文件上传组件
Java实现的文件上传组件有好几种,其中最为“官方”的要数Apache Commons库中的FileUpload了吧. 页面 <form method="POST" enct ...
- bootstrap fileinput 文件上传工具
这是我上传的第二个plugin 首先第一点就是因为这个好看 符合bootstrap的界面风格 第二是可以拖拽(虽然我不常用这个功能 但是这样界面看起来就丰满了很多) 最后不得不吐槽这个的回发事件 我百 ...
- commons.fileupload 文件上传
编辑jsp页面获取文件 <html> <head> <base href="<%=basePath%>"> <title> ...
随机推荐
- knockoutJS学习笔记05:控制文本和外观绑定
测试数据: function Person(name,age){ var self = this; self.name = ko.observable(name); self.age = ko.obs ...
- 琴弦文字 - jquery插件
这是一个基于jquery的琴弦效果插件. 以前曾经见过这个效果,有过尝试的想法但是当时技能点还不够. 前天在火车上偶然想起这个,认真思索了一下,一气呵成 :D 看来最近技能树点偏的不太远. 效果展示 ...
- Angular指令2
scope Create a new scope for this directive rather than inheriting the parent scope. controller Crea ...
- 【JavaScript】【CSS】前端规则摘抄
源:http://zhibimo.com
- php中关于引用(&)详解
php中关于引用(&)详解 php的引用(就是在变量或者函数.对象等前面加上&符号) 在PHP 中引用的意思是:不同的变量名访问同一个变量内容. 与C语言中的指针是有差别的.C语言中的 ...
- java中Arraylist复制方法
方法一: ArrayList<Integer> mycopy=new ArrayList<Integer>(); mycopy=(ArrayList<Integer> ...
- jsp利用application统计在线人数的方法
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ...
- 表格不被内容撑大,且超出的内容变为省略号(css)
今天写代码,发现表格会被内容撑大,影响到了网页的整体布局. 百度了一解决方法,下面是代码和我的备注 table{table-layout: fixed;} //固定表格 table td ...
- 上传github代码
github 自己理解的使用方法 摸索了半天时间了,连查再找 百度 GOOGLE的 真是费了不少劲呀,不过 网上的这个教程 那个教程 看的真是一头雾水呀,很多都是贴过来贴过去 ,不过 还是帮助我不少, ...
- <<< php程序在运行后报“internal server error”错误
上传的php程序在运行后报“internal server error”错误,检查以下两方面: 1.请您检查php程序的属性是否设置为755,如果php程序的属性不是755,那么运行的时候会报“int ...