Skip to content

Instantly share code, notes, and snippets.

@shin1x1
Created November 11, 2010 23:21
Show Gist options
  • Save shin1x1/673426 to your computer and use it in GitHub Desktop.
Save shin1x1/673426 to your computer and use it in GitHub Desktop.
<?php
// authentication
if (!authentication()) {
exit;
}
$filepath = "/path/to/file";
$sizes = getimagesize($filepath);
if (!empty($sizes['mime'])) {
$mime = $sizes['mime'];
} else {
$mime = 'application/octet-stream';
}
header('Content-Type: '.$mime);
header('Content-Size: '.filesize($filepath));
// X-Sendfile
header('X-Sendfile: '.$filepath);
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment