What functions can be used to check the size and dimensions of an uploaded image in PHP?

When working with uploaded images in PHP, it is important to check the size and dimensions to ensure they meet certain requirements. This can be done using functions like `getimagesize()` to get the dimensions and `filesize()` to get the size of the uploaded image. By checking these values, you can enforce size limits or aspect ratio requirements for the images being uploaded.

// Check the dimensions and size of an uploaded image
$uploadedFile = $_FILES['file']['tmp_name'];

// Get the dimensions of the image
list($width, $height) = getimagesize($uploadedFile);

// Get the size of the image
$fileSize = filesize($uploadedFile);

// Check if the dimensions are within a specific range
if ($width > 800 || $height > 600) {
    echo "Image dimensions must be less than or equal to 800x600 pixels.";
}

// Check if the file size is within a specific limit (e.g. 2MB)
if ($fileSize > 2 * 1024 * 1024) {
    echo "Image size must be less than 2MB.";
}