Skip to content

Instantly share code, notes, and snippets.

@taskinoz
Last active August 8, 2019 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taskinoz/378438e6436efd9b5e826a592d6bdb4f to your computer and use it in GitHub Desktop.
Save taskinoz/378438e6436efd9b5e826a592d6bdb4f to your computer and use it in GitHub Desktop.
<?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