title: PHP allowed zip mimetypes
body: <p>I know (from the answer to this question: <a href="https://stackoverflow.com/questions/6977544/rar-zip-files-mime-type">.rar, .zip files MIME Type</a>) that that most people check zip files in PHP as <code>application/zip</code> or <code>application/octet-stream</code>, but I have a couple of questions about this:</p>
  
  <ul>
  <li>is it safe just to check for <code>application/octet-stream</code> (given that <code>application/octet-stream</code> can be used to describe many more file types than just zip!).  I know I could check the file in other ways too, but thought I should try and keep everything as simple as possible </li>
  <li>I've tried to check for as many different actual zip types as possible; but, there are some which give some unexpected results.  I've found 1 for which the mime-type is <code>application/x-external-editor</code>, but PHP has problems dealing with it (although the only error I get is <code>Warning: ZipArchive::close() [ziparchive.close]: Invalid or unitialized Zip object</code>) - is this documented anywhere?  Is there a list of actual <code>x-</code> mimetypes which PHP can cope with?</li>
  </ul>
  
  <p><strong>Edit</strong></p>
  
  <p>In answer to the questions below:</p>
  
  <ul>
  <li>I'm checking the mime type by using <code>$_FILES['fileatt']['type']</code>, but using <code>mime_content_type()</code> gives the same result.  Different zip files seem to be any one of the following: <code>'application/zip'</code>, <code>'application/x-compressed'</code>, <code>'application/x-zip-compressed'</code>, <code>'application/x-compressed'</code>, <code>'multipart/x-zip'</code>.  I didn't understand why I got an error when the mime type was detected as being <code>application/x-external-editor</code>.</li>
  <li>I have got the zip extension installed, and I am extracting all the files from the zip files when they are uploaded. I hadn't thought about checking the error.</li>
  </ul>
  
  <p>I have also found another thing I don't quite understand: when I use the following code with a file which PHP reads as <code>application/x-external-editor</code>:</p>
  
  <pre><code>if($zip-&gt;open($_FILES[fileatt]['tmp_name'])===TRUE)
  {
      echo "success";
  } else {
      echo "error";
  } 
  </code></pre>
  
  <p>prints "error", but checking the file type as</p>
  
  <pre><code>$res = $zip-&gt;open($_FILES[fileatt]['tmp_name']);
  if($res)
  {
      echo "success";
  } else {
      echo "error";
  } 
  </code></pre>
  
  <p>prints "success"; in this code, I assume that the boolean is effectively using <code>==</code>, not <code>===</code>, but why should this make a difference?</p>
  
  <p>The error:</p>
  
  <pre><code>$res = $zip-&gt;open($_FILES[fileatt]['tmp_name']);
  if($res===TRUE)
  {
      echo "success";
  } else {
      echo $res;
  } 
  </code></pre>
  
  <p>prints <code>19</code> - which error (<a href="http://uk3.php.net/manual/en/ziparchive.open.php" rel="nofollow noreferrer">http://uk3.php.net/manual/en/ziparchive.open.php</a>) does 19 refer to?!</p>