title: Check image dimensions (height and width) before uploading image using PHP
body: <p>How can I check for height and width before uploading image, using PHP.</p>
  
  <p>Must I upload the image first and use "getimagesize()"? Or can I check this before uploading it using PHP?</p>
  
  <pre><code>&lt;?php
  
  foreach ($_FILES["files"]["error"] as $key =&gt; $error) {
  if(
  $error == UPLOAD_ERR_OK
  &amp;&amp; $_FILES["files"]["size"][$key] &lt; 500000 
  &amp;&amp; $_FILES["files"]["type"][$key] == "image/gif"
  || $_FILES["files"]["type"][$key] == "image/png"
  || $_FILES["files"]["type"][$key] == "image/jpeg"
  || $_FILES["files"]["type"][$key] == "image/pjpeg" 
  ){
  
  
  $filename = $_FILES["files"]["name"][$key];
  
  
  
  
  
  
  
  
  if(HOW TO CHECK WIDTH AND HEIGHT)
  {
  echo '&lt;p&gt;image dimenssions must be less than 1000px width and 1000px height';
  }
  
  
  }
  
  
  
  
  
  
  
  ?&gt;
  </code></pre>