Skip to content

Instantly share code, notes, and snippets.

@taskinoz taskinoz/ReturnImage.php
Last active Aug 8, 2019

Embed
What would you like to do?
<?php
// Better Script: https://stackoverflow.com/questions/900207/return-a-php-page-as-an-image
// open the file in a binary mode
$name = 'path/to/image.jpg';
$fp = fopen($name, 'rb');
// send the right headers
header("Content-Type: image/png");
header("Content-Length: " . filesize($name));
// dump the picture and stop the script
fpassthru($fp);
exit;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.