How can I ensure that the "save as" prompt appears when clicking on a graphic for download in PHP?

When a user clicks on a graphic for download in PHP, you can ensure that the "save as" prompt appears by setting the appropriate headers in the PHP script. You need to send the correct Content-Type header for the graphic file type (e.g., image/jpeg for JPEG images) and the Content-Disposition header with the value "attachment; filename=yourfilename.extension".

<?php
// Set the content type and disposition headers
header('Content-Type: image/jpeg');
header('Content-Disposition: attachment; filename=yourfilename.jpg');

// Output the graphic file
readfile('path/to/your/graphic.jpg');
?>