__HTML_5读取文件API

//HTML5 __FileSystemApi

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<style>
  .thumb {
    height: 75px;
    border: 1px solid #000;
    margin: 10px 5px 0 0;
  }
</style>

<input type="file" id="files" name="files[]" multiple />
<output id="list"></output>

<script>
  function handleFileSelect(evt) {
    var files = evt.target.files;
    for (var i = 0, f; f = files[i]; i++) {


      var reader = new FileReader();
      reader.onload = function(e){
          var span = document.createElement('span');
          span.innerHTML =this.result;
          document.getElementById('list').insertBefore(span, null);
      }

      reader.readAsText(f);
    //reader.readAsArrayBuffer;
   //reader.readAsBinaryString;
   //reader.readAsDataURL
} } document.getElementById(
'files').addEventListener('change', handleFileSelect, false); </script> </body> </html>

 

posted @ 2013-12-26 17:36  方方和圆圆  阅读(373)  评论(0编辑  收藏  举报

再过一百年, 我会在哪里?