title: Validating a pdf file other than its extension in javascript?
body: <p>I give user the option of uploading a file like this <br></p>
  
  <pre><code>&lt;form action="#" onsubmit="return Checkfiles(this);"&gt;
      &lt;center&gt;&lt;input type="file" id="filename"&gt; 
      &lt;input type="submit" value="Go!"&gt;&lt;/center&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>When user uploads the file, I validate the file using the following javascript function<br></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          function Checkfiles()
          {
          var fup = document.getElementById('filename');
          var fileName = fup.value;
          var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
          if(ext == "pdf" )
          {
          return true;
          } 
          else
          {
          alert("Upload pdf files only");
          fup.focus();
          return false;
          }
          }
      &lt;/script&gt;
  </code></pre>
  
  <p>Evertything is working fine with it.<br>
  <b>But I want to validate file by some other means and not just by its extension</b>
  <br>I will give reason for doing this. I renamed an image file to image.pdf and now its in pdf format but couldnt be opened.<br></p>
  
  <p>So I want to validate a pdf file in exact way. Is there any other way to check other than by its extension?<br>
  <strong>Edit</strong><br>
  I want to do validation at server end using jsp page. So what should I do for that?
  <br>Thanks in ADVANCE :) </p>