title: PHP Image Upload Checking Dimensions
body: <blockquote>
    <p>How can I check the dimensions of an image after it has uploaded and
    delete it if it does not match the dimensions I want?</p>
  </blockquote>
  
  <p>So after digging around I find PHP cannot do dimensions. The solution I am following is:</p>
  
  <ol>
  <li>Upload the file to the server</li>
  <li>Use that new string and check</li>
  <li>Delete it or continue with upload if it
  does not match width and height</li>
  </ol>
  
  <p>This is my code. Can someone show me how to check the current file for dimensions and how to delete the folder and file if not matching?</p>
  
  <pre><code># create our temp dir
      mkdir("./uploads/temp/".$user."/".$mx."/".$hash."/", 0777, true);
      # upload dir settup
      $uploaddir='./uploads/temp/'.$user.'/'.$mx.'/'.$hash.'/';
      $file=$uploaddir . basename($_FILES['file']['name']);
  
      # upload the file first
      if (move_uploaded_file($_FILES['file']['tmp_name'], $file)) {
          # ok so check the height and width
          # if it is not the width and height assigned delete image and folder
          if (image height= and width =){
              unlink($file);
              rmdir($uploaddir);
              $result=0;
          } else {
          # image matches height and width message ok
              $result=1;
          }
      } else {
          # error uploading
          $result=$errormsg;
      }
  </code></pre>