图片通过转base64上传

  var file = files[0];  
       var reader = new FileReader();  
       reader.onload = function()  
       {  
           document.getElementById("filecontent").innerHTML = this.result;  
       };  
       reader.readAsText(file);

 

<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta name="author" content="oscar999">
  <title></title>
  <script>
  function  handleFiles(files)
  {
    if(files.length)
    {
       var file = files[0];
       var reader = new FileReader();
       reader.onload = function()
       {
           document.getElementById("filecontent").innerHTML = this.result;
       };
       reader.readAsText(file);
    }
  }
  </script>
  
  </head>
  <body>
 
  <input type="file" id="file" onchange="handleFiles(this.files)"/>
  <div id="filecontent"></div>
  </body>
</html>

  

http://blog.csdn.net/oscar999/article/details/37499743

posted @ 2018-02-07 17:02  王玉岩  阅读(157)  评论(0编辑  收藏  举报