Skip to content

Instantly share code, notes, and snippets.

@FrancisBaileyH
Created August 10, 2015 18:37
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 FrancisBaileyH/0e4e06097236505bf46b to your computer and use it in GitHub Desktop.
Save FrancisBaileyH/0e4e06097236505bf46b to your computer and use it in GitHub Desktop.
Send a file to a browser
<?php
public function download()
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: '.filesize($file));
readfile($file);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment