What additional headers need to be sent to ensure a PHP file displays an image instead of prompting for download?

When a PHP file is used to display an image, additional headers need to be sent to the browser to specify that the content type is an image and not a file for download. This can be achieved by setting the "Content-Type" header to the appropriate image type (e.g., "image/jpeg" for JPEG images) and then outputting the image data using functions like "readfile" or "echo". By sending the correct headers, the browser will display the image instead of prompting the user to download it.

<?php
// Set the content type header to specify that the output is an image
header('Content-Type: image/jpeg');

// Output the image data (replace 'image.jpg' with the path to your image file)
readfile('image.jpg');
?>