title: How to detect file extension with javascript FileReader
body: <p>I'm using javascript's FileReader and my customized function for reading an JPG-JPEG image,
  My problem is that how it's possible to detect the file extension through my code below and give error to user if the file is not JPG-JPEG:</p>
  
  <pre><code>function readURL(input) {
    if (input.files &amp;&amp; input.files[0]) {
      var reader = new FileReader();
  
      reader.onload = function (e) {
        alert('image has read completely!');
      }
  
      reader.readAsDataURL(input.files[0]);
    }
  }
  </code></pre>