Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<form>
  <input type="file" id="img" multiple>
  </form>
</body>
</html>
 
var imageData = function(files) {
  
  var imgWidth  = 0,
      imgHeight = 0;
  var reader  = new FileReader();
  reader.addEventListener('load',function(theFile) {
    
    var img = new Image();
    img.src = theFile.target.result;
    img.addEventListener('load',function(){
      return {
        imgWidth  :this.width,
        imgHeight :this.height  
      };
      
    });
  });
  reader.readAsDataURL(files);
};
function checkImg() {
  var files = imgs.files;
            
  for (var i = 0; i < files.length; i++){
    console.log(imageData(files[i]).imgWidth);
  }
}
var imgs = document.getElementById('img');
imgs.addEventListener('change',checkImg);
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers