title: Some weird issue with my file upload and jQuery Image height width and new Image()
body: <p>I am developing a system where in A user uploads a image and the JS checks whether minimum width is more than 75 or not.</p>
  
  <p>When we first time upload the file, it alerts a BLANK one.
  On selecting a next file it alerts the result for the file which was selected before, let me explain below.</p>
  
  <ol>
  <li>FIrst I select a Image with width more than 200px, it alerts BLANK / Null / No Data.</li>
  <li>When i then select a Image with less than 200px, ideally it should alert false, but it alerts true ( The result for the file selected before).</li>
  <li>Now to reverify the problem, I select a Image with more than 200px, ideally it should alert false, but it alerts false ( The result for the file selected before).</li>
  </ol>
  
  <p>Can anyone clear this mess? I tried googling but didnt help.</p>
  
  <p>My HTML</p>
  
  <pre><code>&lt;input type="file" id="file" /&gt;
  </code></pre>
  
  <p>My JS : </p>
  
  <pre><code>var _URL = window.URL || window.webkitURL;
  var wid;
  $("#file").change(function(e) {
      var file, img,hei;
      if ((file = $('#file').prop('files')[0])) {
          img = new Image();
          img.onload = function() {
              wid = ((img.width) &gt; 200) ? true:false;
          };
          img.onerror = function() {
              alert( "not a valid file: " + file.type);
          };
          img.src = _URL.createObjectURL(file);
      }
          alert(wid);
  });
  </code></pre>