Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
  </head>
<body>
<form action="#">
  <input type="file" id="files" name="files[]" multiple />
<output id="list"></output>
  
  <input type="submit" value="Submit" />
</form>
</body>
</html>
 
function handleFileSelect(evt) {
  var files = evt.target.files;
  var file;
  
  for (var i=0; i < files.length; i++) {
    file = files[i];
    
    var reader = new FileReader();
    
    reader.readAsDataURL(file);
    alert(reader.readAsDataURL(file));
  }
  
    // Loop through the FileList and render image files as thumbnails.
 for (var i = 0, f; f <= files[i]; i++) {
      // Only process image files.
      if (!f.type.match('image.*')) {
        continue;
      }
      var reader = new FileReader();
      // Closure to capture the file information.
      reader.onload = (function(theFile) {
        return function(e) {
          // Render thumbnail.
          var span = document.createElement('span');
          span.innerHTML = ['<img class="thumb" src="', e.target.result,
                            '" title="', escape(theFile.name), '"/>'].join('');
          document.getElementById('list').insertBefore(span, null);
        };
      })(f);
      // Read in the image file as a data URL.
      reader.readAsDataURL(f);
    } 
  }
  //document.getElementById('files').addEventListener('change', handleFileSelect, false);
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers