文件上传(bootstrap fileinput)
在做Excel文件上传和下载时,原生文件输入框太不美观,从网上找的bootstrap fileinput还是挺漂亮的,

需要引用的文件 //4.fileUpload
bundles.Add(new ScriptBundle("~/Script/FileUploadJs").Include(
"~/Scripts/FileUpload/zh.js",
"~/Scripts/FileUpload/fileinput.min.js"));
bundles.Add(new StyleBundle("~/Css/FileUploadCss").Include(
"~/Css/FileUpload/fileinput.min.css"));
html中嵌入
<div class="modal fade" id="ImportModel" tabindex="-1" role="dialog" aria-labelledby="#myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">从Execl导入员工</h4>
</div>
<div class="modal-body">
<form id="formtt" class="form-horizontal">
<div class="form-group" style="margin-top:15px">
<a href="~/Excel/Template/UserTemplate.xlsx" class="form-control" style="border:none;">下载导入模板</a>
<input id="txt_file" type="file" multiple class="file" data-overwrite-initial="false">
<br>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
<button type="button" id="btn_submit" class="btn btn-primary" data-dismiss="modal"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
</div>
</div>
</div>
</div>
相关Js代码如下
//初始化fileinput
var FileInput = function () {
var oFile = new Object();
//初始化fileinput控件(第一次初始化)
oFile.Init = function (ctrlName, uploadUrl) {
var control = $('#' + ctrlName);
//初始化上传控件的样式
control.fileinput({
uploadUrl: uploadUrl, //上传的地址
allowedFileExtensions: ['jpg', 'gif', 'png','xlsx'],//接收的文件后缀
showUpload: true, //是否显示上传按钮
showCaption: false,//是否显示标题
overwriteInitial: false,
browseClass: "btn btn-primary", //按钮样式
dropZoneEnabled: false,//是否显示拖拽区域
enctype: 'multipart/form-data',
validateInitialCount: true,
previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}!",
});
//导入文件上传完成之后的事件
$("#txt_file").on("fileuploaded", function (event, data, previewId, index) {
$("#div_startimport").show();
});
}
return oFile;
};
当然初始化时可设置的选项远不止这些,组件功能强大,灵活性也比较强
做后端,js代码基本的能写,html布局及美化实在是不咋样,所以基本都是借助网上开放的组件资源,去学习拿来用
下篇文章介绍一款开源的操作Excel文件的组件EPPlus,用着感觉比NPOI方便些
文件上传(bootstrap fileinput)的更多相关文章
- Bootstrap 文件上传插件 FileInput的使用问题
: 在使用bootstrap的文件上传插件fileinput http://plugins.krajee.com/file-input的预览功能时,删除预览图片在 bootstrap 模态框中没有用, ...
- 基于Ajax的文件上传使用FileInput插件(使用谷歌翻译作者的原文,大致意思是对的,自己把握)
bootstrap-fileinput 说明文档:http://plugins.krajee.com/file-input 有许多人希望学习使用bootstrap-fileinput jQuery插件 ...
- Bootstrap Fileupload 文件上传
1.在jsp中引入css与js文件, <link href="${ctx}/plugins/fileup/css/fileinput.css" media="all ...
- ***文件上传控件bootstrap-fileinput的使用和参数配置说明
特别注意: 引入所需文件后页面刷新查看样式奇怪,浏览器提示错误等,可能是因为js.css文件的引用顺序问题,zh.js需要在fileinput.js后面引入.bootstrap最好在filein ...
- JS组件系列——Bootstrap文件上传组件:bootstrap fileinput
前言:之前的三篇介绍了下bootstrap table的一些常见用法,发现博主对这种扁平化的风格有点着迷了.前两天做一个excel导入的功能,前端使用原始的input type='file'这种标签, ...
- .net core版 文件上传/ 支持批量上传,拖拽以及预览,bootstrap fileinput上传文件
asp.net mvc请移步 mvc文件上传支持批量上传,拖拽以及预览,文件内容校验 本篇内容主要解决.net core中文件上传的问题 开发环境:ubuntu+vscode 1.导入所需要的包:n ...
- 结合bootstrap fileinput插件和Bootstrap-table表格插件,实现文件上传、预览、提交的导入Excel数据操作流程
1.bootstrap-fileinpu的简单介绍 在前面的随笔,我介绍了Bootstrap-table表格插件的具体项目应用过程,本篇随笔介绍另外一个Bootstrap FieInput插件的使用, ...
- 基于bootstrap的上传插件fileinput实现ajax异步上传功能(支持多文件上传预览拖拽)
首先需要导入一些js和css文件 ? 1 2 3 4 5 6 <link href="__PUBLIC__/CSS/bootstrap.css" rel="exte ...
- BootStrap fileinput.js文件上传组件实例代码
1.首先我们下载好fileinput插件引入插件 ? 1 2 3 <span style="font-size:14px;"><link type="t ...
随机推荐
- 数据类型总结——null和undefined
相关文章 简书原文:https://www.jianshu.com/p/c3e252efe848 数据类型总结——概述:https://www.cnblogs.com/shcrk/p/9266015. ...
- 数据类型总结——Boolean类型(布尔类型)
相关文章 简书原文:https://www.jianshu.com/p/e5c75d4be636 数据类型总结——概述:https://www.cnblogs.com/shcrk/p/9266015. ...
- 重拾c语言之动态内存分配
动态内存分配 传统数组的缺点: 1数组长度必须事先制定,且仅仅能是长整数不能是变量 2传统形式定义的数组该数组的内存程序无法手动释放 3数组一旦定义,系统就会为该数组分配的存储空间就会一直存在直到该函 ...
- mysql查询字段所在表
use information_schema;select * from columns where column_name='字段名' ;
- 离线下载chrome
https://gallery.technet.microsoft.com/Google-Chrome-version-f0619a1f
- ArcGIS Runtime支持的GP工具列表(转 )
转自原文 ArcGIS Runtime支持的GP工具列表(转 ) 目前ArcGIS Runtime有两个版本 Basic 版本和Standard版本,而Basic版本不支持Geoprocessing( ...
- 获取WebConfig 配置项的值
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.C ...
- Windows批处理(cmd/bat)常用命令
Windows批处理(cmd/bat)常用命令 一.总结 一句话总结: 1.批量处理图片的方式? PS批处理是基于强大的图片编辑软件Photoshop的,用来批量处理图片的脚本: 2.大量的重复的操作 ...
- 避免if语句的深层次嵌套
公司做了个抢红包的限制,然后ajax请求的返回字段,要进行多层逻辑的判断,想想是真恶心,虽然都是简单逻辑,而且看别人以前写的代码,发现,哎,注释能不能写上吶,像我写代码都是细致到,哪怕初学者也能看懂这 ...
- 【9206】 奖学金(NOIP2007)
Time Limit: 10 second Memory Limit: 2 MB 问题描述 某小学最近得到了一笔赞助,打算拿出其中一部分为学习成绩优秀的前5名学生发奖学金.期末,每个学生都有3门课的成 ...