Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <script>
    function getFile() {
      var file = document.getElementById('file').files[0]
      
      var reader = new FileReader()
     // 获取base64格式字符串文件内容
     reader.readAsDataURL(file)
     reader.onload = function(data) {
       var img = new Image()
       img.src = data.target.result
       var that = this
       img.onload = function() {
         console.log(this.width, this.height)
       }
     }
    }
  </script>
</head>
<body>
 <input type="file" id="file" accept="image/*">
 <button onclick="getFile()">获取宽高</button>
</body>
</html>
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers