How can the dimensions (height and width) of an uploaded file be retrieved using PHP's $_FILE array?
To retrieve the dimensions (height and width) of an uploaded file using PHP's $_FILE array, you can use the getimagesize() function. This function returns an array containing the image width and height along with other information. By accessing the width and height values from the returned array, you can retrieve the dimensions of the uploaded file.
$uploadedFile = $_FILES['file']['tmp_name'];
list($width, $height) = getimagesize($uploadedFile);
echo "Width: " . $width . " pixels<br>";
echo "Height: " . $height . " pixels";
Keywords
Related Questions
- What are the potential pitfalls of using magic constants like __FILE__ and __DIR__ to get folder names in PHP?
- What resources or tutorials are recommended for PHP beginners to learn how to interact with databases and display data in a structured format on a webpage?
- What are the best practices for securely storing and updating user data in PHP sessions?