Created
January 10, 2013 01:22
-
-
Save hanafiah/4498605 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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