input标签处理多文件上传

var input = document.getElementById('upload');

input标签处理多文件上传,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...

http://www.bkjia.com/HTML5/1311220.htmlwww.bkjia.comtruehttp://www.bkjia.com/HTML5/1311220.htmlTechArticleinput标签处理多文件上传,input标签文件上传 !DOCTYPE html html head meta charset = "UTF-8" meta name ="viewport" content ="width=device-width, initial-scale=1, maxim...

</head>

 

    console.info("输出文件数据");

<title>多个文件上传</title>

    }

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">

    console.info(baseFileStr);

</div>

</script>

</body>

 

<script>

    reader.onloadend = function(e) {

      var reader = new FileReader();

 

<head>

 

>>>输出文件数据

<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;" />

本文由金沙官网线上发布于Web前端,转载请注明出处:input标签处理多文件上传

您可能还会对下面的文章感兴趣: