官网:
 
HTML页面:
引用:
<link href="~/BootstrapComponent/css/fileinput.css" rel="stylesheet" />
<script src="~/BootstrapComponent/js/fileinput.js"></script>
<script src="~/BootstrapComponent/js/locales/zh.js"></script>
<!--容器-->
<input id="inputFile" type="file" class="file" data-preview-file-type="text" name="file">
<!--JS代码-->
<script>
//初始化fileinput控件
$("#inputFile").fileinput({
language: 'zh',
autoReplace: false,
maxFileCount: 1,
allowedFileExtensions: ["jpg", "png", "gif"],
browseClass: "btn btn-primary", //按钮样式
previewFileIcon: "<i class='glyphicon glyphicon-king'></i>"
});
</script>
fileinput.js文件参数修改:
$.fn.fileinput.defaults = {
language: 'en',
showCaption: true,
showBrowse: true,
showPreview: true,
showRemove: true,
showUpload: false, //若为同步提交,无需显示组件的上传按钮
showCancel: true,
showClose: true,
   ...
  }
MVC控制器:
        /// <summary>
/// MVC文件上传后台方法
/// </summary>
/// <returns></returns>
public JsonResult FileUpload()
{
string text = "位置错误!";
bool isSuccess = false;
var files = Request.Files;
if (files != null && files.Count > )
{
try
{
var file = files[];
var fileName = file.FileName;
var filePath = Path.Combine(HttpRuntime.AppDomainAppPath, "image", fileName); //绝对路径
file.SaveAs(filePath);
isSuccess = true;
text = "上传成功!";
}
catch (Exception e)
{
text = e.Message;
}
}
return Json(new { Success = isSuccess, Message = text }, JsonRequestBehavior.AllowGet);
}

Bootstrap-FileInput组件的简单Demo的更多相关文章

  1. bootstrap fileinput组件的使用

    组件的下载地址为:https://github.com/kartik-v/bootstrap-fileinput 比较详细的介绍可参看:http://www.jq22.com/jquery-info5 ...

  2. Bootstrap fileinput.js,最好用的文件上传组件

    本篇介绍如何使用bootstrap fileinput.js(最好用的文件上传组件)来进行图片的展示,上传,包括springMVC后端文件保存. 一.demo   二.插件引入 <link ty ...

  3. bootstrap fileinput 使用记录

    第一次使用bootstrap fileinput碰到了许多坑,做下记录 需求 本次使用bootstrap fileinput文件上传组件,主要用来上传和预览图片.作为一个后台管理功能,为某个表的某个字 ...

  4. JS组件系列——Bootstrap文件上传组件:bootstrap fileinput

    前言:之前的三篇介绍了下bootstrap table的一些常见用法,发现博主对这种扁平化的风格有点着迷了.前两天做一个excel导入的功能,前端使用原始的input type='file'这种标签, ...

  5. BootStrap fileinput.js文件上传组件实例代码

    1.首先我们下载好fileinput插件引入插件 ? 1 2 3 <span style="font-size:14px;"><link type="t ...

  6. Bootstrap文件上传组件:bootstrap fileinput

    为了上传预览pdf与图片特用此插件. 源码以及API地址: bootstrap-fileinput源码:https://github.com/kartik-v/bootstrap-fileinput ...

  7. bootstrap fileinput控件 + django后台上传、回显简单使用

    一.控件下载:https://github.com/kartik-v/bootstrap-fileinput/ 官网:http://plugins.krajee.com/file-input 需要引入 ...

  8. 结合bootstrap fileinput插件和Bootstrap-table表格插件,实现文件上传、预览、提交的导入Excel数据操作流程

    1.bootstrap-fileinpu的简单介绍 在前面的随笔,我介绍了Bootstrap-table表格插件的具体项目应用过程,本篇随笔介绍另外一个Bootstrap FieInput插件的使用, ...

  9. JS组件系列——两种bootstrap multiselect组件大比拼

    前言:今天继续来看看bootstrap的另一个组件:multiselect.记得在项目开始之前,博主项目组几个同事就使用哪些js组件展开过讨论,其中就说到了select组件,由于项目的整体风格使用的b ...

随机推荐

  1. 【翻译自mos文章】怎么正确的计算一个ip地址的subnet id?

    怎么正确的计算一个ip地址的subnet id? 来源于: How to calculate the correct subnet for an interface (文档 ID 1059759.1) ...

  2. Java获取项目路径下的方法(全)

    平时敲代码的时候,非常多时候提示文件找不到,而抛出了异常,如今整理例如以下 一 相对路径的获得 说明:相对路径(即不写明时候究竟相对谁)均可通过下面方式获得(不论是一般的java项目还是web项目) ...

  3. Git 跟 GitHub 是什么关系?

    Git 跟 GitHub 是什么关系? 大概就是「魔兽争霸」与「对战平台」的关系吧. git是一个版本控制工具github是一个用git做版本控制的项目托管平台. git是一个版本管理工具,githu ...

  4. WIN7使用VisualSVN建立SVN服务器

    使用SVN开发十分的方便,这样就不用每次都拷贝粘贴来备份了,网上看到一篇给自己的windows电脑安装SVN服务器的使用非常方便. 1.下载安装文件(服务器端和客户端) 服务器端采用VisualSVN ...

  5. [jzoj 4528] [GDOI2019模拟2019.3.26] 要换换名字 (最大权闭合子图)

    题目链接: https://jzoj.net/senior/#contest/show/2683/0 题目: 题解: 不妨枚举一个点,让两颗树都以这个点为根,求联通块要么点数为$0$,要么包括根(即联 ...

  6. Web前端错题模糊题记录

    title: Web前端错题模糊题记录 toc: true date: 2018-09-20 10:04:36 categories: Web tags: HTML CSS JavaScript HT ...

  7. 启动项目报错:org.springframework.beans.factory.UnsatisfiedDependencyException

    dubbo项目: 启动项目报错:(web端) org.springframework.beans.factory.UnsatisfiedDependencyException: Error creat ...

  8. H.264标准(一)mp4封装格式详解

    在网络层,互联网提供所有应用程序都要使用的两种类型的服务,尽管目前理解这些服务的细节并不重要,但在所有TCP/IP概述中,都不能忽略他们: 无连接分组交付服务(Connectionless Packe ...

  9. C++之指针与引用,函数和数组

    ]={,,}; //ptr是指针,该指针类型是int[3] ]=&arr; cout << **ptr << endl;//第一次解指针时得到数组地址,第二次解指针取数 ...

  10. matplotlib bar函数重新封装

    参考: https://blog.csdn.net/jenyzhang/article/details/52047557 https://blog.csdn.net/liangzuojiayi/art ...