Skip to content

Instantly share code, notes, and snippets.

@WebFikirleri
Created April 1, 2015 09:43
Show Gist options
  • Save WebFikirleri/a8f05a32befcb67d58e9 to your computer and use it in GitHub Desktop.
Save WebFikirleri/a8f05a32befcb67d58e9 to your computer and use it in GitHub Desktop.
PHP: Download A File
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment