What are the potential pitfalls of relying on the MIME-Type provided by the browser for image uploads in PHP?
Relying solely on the MIME-Type provided by the browser for image uploads in PHP can be risky as it can be easily manipulated by the user. To mitigate this risk, you should also validate the uploaded file using PHP's `getimagesize()` function to ensure it is actually an image file.
// Validate uploaded image file using getimagesize()
$image_info = getimagesize($_FILES["file"]["tmp_name"]);
if($image_info === false) {
die("Invalid image file.");
}
// Continue with your image upload process