title: How can I get a file's upload size using simple Javascript?
body: <p>I have upload file functionality on one of the page. I check for the extension of the file using JavaScript. Now i want to restrict the user from uploading file greater than 1 MB. Is there any way i can check the file upload size using JavaScript.</p>
  
  <p>My code currently look like this:</p>
  
  <pre><code>&lt;script language="JavaScript"&gt;
  function validate() {
     var filename = document.getElementById("txtChooseFile").value;
     var ext = getExt(filename);
     if(ext == "txt" || ext == "csv")
        return true;
     alert("Please upload Text files only.");
     return false;
  }
  
  function getExt(filename) {
     var dot_pos = filename.lastIndexOf(".");
     if(dot_pos == -1)
        return "";
     return filename.substr(dot_pos+1).toLowerCase();
  }
  &lt;/script&gt;
  </code></pre>