title: PHP: File upload not verifying file type
body: <p>I am trying to upload an image file.</p>
  
  <p>I receive the file name and OK and there are no errors, but for some reason when it reaches my file type if/else statement:</p>
  
  <pre><code>if($filetype != 'image/jpeg' || $filetype != 'image/jpg' || $filetype != 'image/png' || $filetype != 'image/gif') {
  //ERROR - NOT CORRECT TYPE
  }
  else {
  //CORRECT FILE TYPE..CONTINUE
  }
  </code></pre>
  
  <p>it will alsways say the file type is wrong. Ive tried with a few different file types of various sizes to no avail.</p>
  
  <p>My full code is:</p>
  
  <pre><code>  if(!$_FILES['photo'.$i]['error'])
    {
     echo "&lt;br /&gt;NO ERRORS FOUND";
  
        //FILE TYPE CHECKER
        $filetype = $_FILES['photo'.$i]['type'];
        echo "&lt;br /&gt;FILE TYPE: " . $filetype;
  
        if($filetype != 'image/jpeg' || $filetype != 'image/jpg' || $filetype != 'image/png' || $filetype != 'image/gif') {
          $valid_file = false;
          $message = 'Wrong file type. Please only upload jpg, jpeg, gif or png files';
        }//END FILE CHECKER IF
  
        else {
          echo "&lt;br /&gt;FILE TYPE OK";
        }//END FILE TYPE CHECK ELSE
  
    }
  </code></pre>
  
  <p>The line <code>echo "&lt;br /&gt;FILE TYPE: " . $filetype;</code> shows I am uploading the correct file type (eg: FILE TYPE: image/png), just the if statement doesnt react...</p>
  
  <p>Would anyone know why this is occurring? </p>