title: serving .docx files through my webserver are corrupt when opened
body: <p>i though i found the answer here:
  <a href="https://stackoverflow.com/questions/4602678/serving-docx-files-through-php">Serving .docx files through Php</a>
  But i am still getting the error that the file is corrupt when trying to download and open a docx server via php
  Maybe you can see something wrong with my code. The .doc works fine it is the docx that fail.</p>
  
  <pre><code>$parts = pathinfo($doc);
  $docFile = $userDocRoot.$doc;
  if ( !file_exists($docFile) ){
      throw new Exception("Can not find ".$parts ['basename']." on server");
  }
  if ( $parts['extension'] == 'docx' ){
      header('Content-type: application/vnd.openxmlformats- officedocument.wordprocessingml.document');
      header('Content-Disposition: attachment; filename="'.$parts['basename'].'"');
      header('Expires: 0');
      header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
      header('Pragma: public');
      ob_clean();
      flush();
      readfile($docFile);
  }else{
     header('Content-type: application/msword');
     header('Content-Disposition: attachment; filename="'.$parts['basename'].'"');
     readfile($docFile);
  }
  </code></pre>