mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 10:22:18 +00:00
Adapted DMSLib download method to be more generic
DMSLib now extends FHC Controller to use its new method 'outputFile', which sets HTTP headers and reads the file. DMSLib uses now download function to accept params from Controller like own filename or special disposition. Loading document and retrieving file info is outsourced into own method to be reusable. Signed-off-by: cris-technikum <hainberg@technikum-wien.at>
This commit is contained in:
@@ -132,6 +132,32 @@ abstract class FHC_Controller extends CI_Controller
|
||||
{
|
||||
$this->output->set_content_type('application/json')->set_output(json_encode($mixed));
|
||||
}
|
||||
|
||||
protected function outputFile($fileObj)
|
||||
{
|
||||
if (file_exists($fileObj->file))
|
||||
{
|
||||
$finfo = new finfo(FILEINFO_MIME);
|
||||
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: '. $finfo->file($fileObj->file));
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($fileObj->file));
|
||||
|
||||
if (isset($fileObj->disposition) && ($fileObj->disposition == 'inline' || $fileObj->disposition == 'attachment'))
|
||||
{
|
||||
header('Content-Disposition: '. $fileObj->disposition. '; filename="'. $fileObj->name. '"');
|
||||
}
|
||||
|
||||
readfile($fileObj->file);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Private methods
|
||||
|
||||
Reference in New Issue
Block a user