title: PHP error handling in file upload
body: <p>I want to put out an error message when the uploaded image size is over 3MB.
  This is my current code. It puts out an error message properly when an image is over 3MB, but it also puts out an error message when no image is uploaded. How do I fix this?</p>
  
  <pre><code>//image check start
  if ((($_FILES["file"]["type"] == "image/gif")
  || ($_FILES["file"]["type"] == "image/jpeg")
  || ($_FILES["file"]["type"] == "image/png")
  || ($_FILES["file"]["type"] == "image/pjpeg"))
  &amp;&amp; ($_FILES["file"]["size"] &lt; 3072000))
  //image check end
  {
      if($_FILES['file']['size'] &gt; 0)
      {
          file uploading script
      } else {
          do nothing
      }
  } else {
      error("Maximum image size exceeded or invalid file format.");
  }
  </code></pre>