Skip to content

Instantly share code, notes, and snippets.

@hanafiah
Created January 10, 2013 01:22
Show Gist options
  • Save hanafiah/4498605 to your computer and use it in GitHub Desktop.
Save hanafiah/4498605 to your computer and use it in GitHub Desktop.
<?php
function loadimg($img)
{
//absolute path
$fullPath = '/private/'.$img;
if (is_readable($fullPath)) {
$mime = mime_content_type($fullPath);
header('Content-type: ' . $mime);
header('Content-length: ' . filesize($fullPath));
@readfile($fullPath);
exit;
}
echo 'No Image';
//or can return 404
//header("Status: 404 Not Found");
exit;
}
//test
$img = isset($_GET['img']) ? $_GET['img'] : '';
loadimg($img);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment