bootstrap文件上传fileupload插件
Bootstrap FileInput中文API整理:https://blog.csdn.net/u012526194/article/details/69937741
SpringMVC + bootstrap fileupload 多文件上传:https://blog.csdn.net/fanxiangru999/article/details/61927385
bootstrap fileupload 使用详解:https://blog.csdn.net/fanxiangru999/article/details/63756730
源码以及API地址:
bootstrap-fileinput源码:https://github.com/kartik-v/bootstrap-fileinput
bootstrap-fileinput在线API:http://plugins.krajee.com/file-input
bootstrap-fileinput Demo展示:http://plugins.krajee.com/file-basic-usage-demo
前后端单文件上传代码:
@ResponseBody
@RequestMapping(value="/upload", method = RequestMethod.POST)
public JSONObject upload(@RequestParam("file") MultipartFile file, HttpServletRequest request ) {
System.out.println("上传开始");
JSONObject json = new JSONObject();
json.put("code", "1");
if( file.isEmpty() ) {
json.put("msg", "上传文件为空");
return json;
}else {
String savePath = request.getServletContext().getRealPath("/upload/");
String fileName=file.getOriginalFilename();
String pathname = savePath + fileName;
File dest = new File(pathname);
if( !dest.getParentFile().exists() ) {
dest.getParentFile().mkdirs();
}
try {
file.transferTo(dest);
json.put("code", 1);
json.put("msg", "上传成功");
json.put("imgPath", pathname);
return json;
} catch (Exception e) {
json.put("msg", e.getMessage());
return json;
}
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html>
<!-- release v4.1.8, copyright 2014 - 2015 Kartik Visweswaran -->
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>上传文件测试</title>
<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet">
<link href="<%=basePath%>css/fileinput.min.css" media="all" rel="stylesheet" type="text/css" />
<script src="<%=basePath%>js/jquery-3.2.1.min.js"></script>
<script src="<%=basePath%>js/fileinput.min.js" type="text/javascript"></script>
<script src="<%=basePath%>js/fileinput_locale_zh.js" type="text/javascript"></script>
<script src="<%=basePath%>js/bootstrap.min.js" type="text/javascript"></script>
</head> <body>
<div class="container">
<div class="row" style="height: 500px">
<input id="file-0" class="file" type="file" multiple data-min-file-count="1" name="file">
</div>
</div> <script type="text/javascript">
//初始化fileinput控件(第一次初始化)
function initFileInput(ctrlName, uploadUrl) {
var control = $('#' + ctrlName);
control.fileinput({
language: 'zh', //设置语言
uploadUrl: uploadUrl, //上传的地址
allowedFileExtensions : ['jpg', 'png','gif'],//接收的文件后缀
showUpload: true, //是否显示上传按钮
showCaption: false,//是否显示标题
browseClass: "btn btn-primary", //按钮样式
previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
});
}
//初始化fileinput控件(第一次初始化)
initFileInput("file-0", "/upload");
</script>
</body>
</html>
bootstrap文件上传fileupload插件的更多相关文章
- 基于Metronic的Bootstrap开发框架经验总结(5)--Bootstrap文件上传插件File Input的使用
Bootstrap文件上传插件File Input是一个不错的文件上传控件,但是搜索使用到的案例不多,使用的时候,也是一步一个脚印一样摸着石头过河,这个控件在界面呈现上,叫我之前使用过的Uploadi ...
- Bootstrap文件上传插件File Input的使用
基于Metronic的Bootstrap开发框架经验总结(5)--Bootstrap文件上传插件File Input的使用 Bootstrap文件上传插件File Input是一个不错的文件上传控件, ...
- (转)基于Metronic的Bootstrap开发框架经验总结(5)--Bootstrap文件上传插件File Input的使用
http://www.cnblogs.com/wuhuacong/p/4774396.html Bootstrap文件上传插件File Input是一个不错的文件上传控件,但是搜索使用到的案例不多,使 ...
- JS组件系列——Bootstrap文件上传组件:bootstrap fileinput
前言:之前的三篇介绍了下bootstrap table的一些常见用法,发现博主对这种扁平化的风格有点着迷了.前两天做一个excel导入的功能,前端使用原始的input type='file'这种标签, ...
- Bootstrap文件上传组件
前言:之前的三篇介绍了下bootstrap table的一些常见用法,发现博主对这种扁平化的风格有点着迷了.前两天做一个excel导入的功能,前端使用原始的input type='file'这种标签, ...
- Bootstrap 文件上传插件 FileInput的使用问题
: 在使用bootstrap的文件上传插件fileinput http://plugins.krajee.com/file-input的预览功能时,删除预览图片在 bootstrap 模态框中没有用, ...
- Bootstrap文件上传组件:bootstrap fileinput
为了上传预览pdf与图片特用此插件. 源码以及API地址: bootstrap-fileinput源码:https://github.com/kartik-v/bootstrap-fileinput ...
- python 全栈开发,Day75(Django与Ajax,文件上传,ajax发送json数据,基于Ajax的文件上传,SweetAlert插件)
昨日内容回顾 基于对象的跨表查询 正向查询:关联属性在A表中,所以A对象找关联B表数据,正向查询 反向查询:关联属性在A表中,所以B对象找A对象,反向查询 一对多: 按字段:xx book ----- ...
- Django与Ajax,文件上传,ajax发送json数据,基于Ajax的文件上传,SweetAlert插件
一.Django与Ajax AJAX准备知识:JSON 什么是 JSON ? JSON 指的是 JavaScript 对象表示法(JavaScript Object Notation) JSON 是轻 ...
随机推荐
- 7 . 动态sql-choose
choose-when-otherwise 只能满足一个when 中的条件,互斥的条件,不能同时存在 mapper.xml <select id="selectstateByTitle ...
- Qt 学习之路 2(15):标准对话框 QMessageBox
Qt 学习之路 2(15):标准对话框 QMessageBox 豆子 2012年9月18日 Qt 学习之路 2 40条评论 所谓标准对话框,是 Qt 内置的一系列对话框,用于简化开发.事实上, ...
- cs231n学习笔记(二)图像分类
图像分类可说是计算机视觉中的基础任务同时也是核心任务,做好分类可为检测,分割等高阶任务打好基础. 本节课主要讲了两个内容,K近邻和线性分类器,都是以猫的分类为例. 一. K近邻 以猫的分类为例,一张含 ...
- hdu6397 Character Encoding 隔板法+容斥原理+线性逆元方程
题目传送门 题意:给出n,m,k,用m个0到n-1的数字凑出k,问方案数,mod一个值. 题目思路: 首先如果去掉数字范围的限制,那么就是隔板法,先复习一下隔板法. ①k个相同的小球放入m个不同的盒子 ...
- Mysql5.7.20源码编译安装
一.下载源码包 1.1 下载mysql源码包 MySQL源码,网址为:https://dev.mysql.com/downloads/mysql/ : 1.2 下载boost 下载网址为:http:/ ...
- esper(4-2)-Category Context
语法: create context context_name group [by] group_expression as category_label [, group [by] group_ex ...
- ubuntu 常用安装软件
1. Ubuntu安装chrome. sudo apt-get install chromium-browser w
- MySQL 0 学习
ubuntu 安装mysql 创建用户 以及外部如何可视化连接的 方法 https://www.linuxidc.com/Linux/2017-01/139502.htm 2.3 MyS ...
- 牛客网练习赛28A
题目链接:https://www.nowcoder.com/acm/contest/200/A 链接:https://www.nowcoder.com/acm/contest/200/A来源:牛客网 ...
- 微信web开发者工具 && 微信调试页面
微信开发者工具 做微信公众号的过程中,自然避免不了登录账号然后进行调试,但是在chrome上我们没有办法登录,这是一个令人头疼的问题,比如这个公众号网页,只会提示出错,因为开发者限制了公众号网页的登录 ...