Skip to content

Instantly share code, notes, and snippets.

@nomaster
Last active August 29, 2015 14:02
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 nomaster/f09fbae5eb2bc1f90d5c to your computer and use it in GitHub Desktop.
Save nomaster/f09fbae5eb2bc1f90d5c to your computer and use it in GitHub Desktop.
X-Sendfile in PHP
<?php
sendfile() {
header( 'X-Sendfile: '.$file ); // Apache webserver
header( 'X-Accel-Redirect: '.$file ); // Nginx webserver
header( 'Content-Type: application/octet-stream' ); // set correct mime type here
header( 'Content-Disposition: attachment; filename='.$filename );
exit;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment