input标签处理多文件上传
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<title>多个文件上传</title>
</head>
<body>
<div style="height: 100px; width: 100px; border: 1px solid red; position: relative;">
点击上传
<input onchange="uploadFile()" id="upload" multiple="multiple" type="file" accept="image/*;capture=camera" style="height: 100px;width: 100px;opacity: 0;position: absolute;top: 0;left: 0;" />
</div>
<script>
function uploadFile() {
var input = document.getElementById('upload');
var files = Array.prototype.slice.call(input.files);
files.forEach(function(file, i) {
var reader = new FileReader();
reader.onloadend = function(e) {
var baseFileStr = this.result.substring((13 + file.type.length),this.result.length);
console.info("输出文件数据");
console.info(baseFileStr);
}
reader.readAsDataURL(file);
});
}
</script>
</body>
</html>
>>>输出文件数据
>>>iVBORw0KGgoAAAANSUhEUgAAABIAAAAOCAYAAAAi2...
最新文章
- ActiveMQ 简单搭建
- Java 日期加减计算.
- string.Format格式化
- ExtJs Ext.panel.Panel和Ext.container.Viewport布局问题
- c/c++ 重载 数组 操作符[] operator[ is ambiguous, as 0 also mean a null pointer of const char* type.
- 【转】 U3D DrawCall优化手记 - 夜阑卧听风吹雨
- md5实现
- linux新建磁盘并分区
- Oracle判断指定列是否全部为数字
- linux---Vim命令集
- Linux双网卡NAT共享上网
- Chapter 2 Open Book——16
- C语言5种存储区域
- jpa报错:Table &#39;dev-test.hibernate_sequence&#39; doesn&#39;t exist
- Python 3 基本操作列举
- jvm(转)
- Jnekins+Gitlab代码提交全程配置
- 利用vue-cli3快速搭建vue项目详细过程
- VNC远程连接阿里云Linux服务器 图形界面
- vs2017调试浏览器闪退
热门文章
- 葵花宝典之机器学习:全网最重要的AI资源都在这里了(大牛,研究机构,视频,博客,书籍,Quora......)
- CentOS 7安装过程
- HDU 3987 &;&; DINIC
- JS禁用右键+禁用Ctrl+u+禁用F12
- Linux学习笔记——例说makefile 索引博文
- 【转】selenium自动化测试环境搭建
- hdu 1698 Just a Hook 基本线段树
- linux for LVM 创建笔记
- 如何用jquery+ajax写省市区的三级联动?(封装和不封装两种方式)-----2017-05-14
- java三大版本解析