title: How to detect .docx correct MIME other than application/octet-stream
body: <p>I have a website that uploads documents to the server and insert them into Mysql tables.</p>
  
  <p>In the process the server (via PHP) examns the type of the file to decide whether rejecting it or save it, and I do this via posting the </p>
  
  <blockquote>
    <p>$_FILES["file"]["type"]</p>
  </blockquote>
  
  <p>and be sure it equals to:</p>
  
  <blockquote>
    <p>application/vnd.openxmlformats-officedocument.wordprocessingml.document</p>
  </blockquote>
  
  <p>However, in some cases the posted file type appeares to be:</p>
  
  <blockquote>
    <p>application/octet-stream</p>
  </blockquote>
  
  <p><strong>Is this because the client doesn't have MS Word installed on the device?</strong></p>
  
  <p>If this is the case, is it <strong>NOT</strong> safe to verify <code>application/octet-stream</code> to be one of the allowed file types? given that it's for generic MIME as per my understanding; which means any file type including <code>.exe</code> would be allowed? (it goes without saying what issues would this cause).</p>
  
  <p>Is there some other way to validate the file type <code>.docx</code> even if no MS Word installed? or whatever the reason behind such? I have seen other websites allow uploading <code>.docx</code> files even from mobile devices that don't have such installed.</p>
  
  <p>Thanks for the help.</p>