Created
April 2, 2014 18:38
-
-
Save nickweavers/9940340 to your computer and use it in GitHub Desktop.
A view/tmpl file to show send a files contents to the browser with appropriate headers
This file contains hidden or 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 | |
// no direct access | |
defined( '_JEXEC' ) or die( 'Restricted access' ); | |
header("Cache- Control: no-cache, must-revalidate" ); // HTTP/1.1 | |
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past | |
$doc = $this->archivingModel->getFile($this->form_data['id_file']); | |
$file_type = $doc->content_type; | |
$content_body = $doc->content_body; | |
header("Content-Type: " . $file_type); | |
$output = fopen("php://output", "w"); | |
if (fwrite($output, $content_body) === FALSE) { | |
$status = "* ERROR - Cannot write to php://output\n\n"; | |
} else { | |
$status = "* File successfully written to php://output\n\n"; | |
} | |
fclose($output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment