-
-
Save henrikbjorn/451210 to your computer and use it in GitHub Desktop.
This file contains 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 | |
class DownloaderComponent extends Object | |
{ | |
public function sendFileHeaders($path) | |
{ | |
$handle = finfo_open(FILEINFO_MIME_TYPE); | |
$contentType = finfo_file($handle, $path); | |
$extension = path_info($path, PATHINFO_EXTENSION); //Better way to get the extension | |
header("Pragma: public"); | |
header("Expires: 0"); | |
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | |
header("Cache-Control: private",false); // required for certain browsers | |
header("Content-Type: $contenttype"); | |
header("Content-Disposition: attachment; filename=\"" . basename($path) . "\";"); | |
header("Content-Transfer-Encoding: binary"); | |
readfile($path); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment